sample app: mem leak
syscrusher opened this issue · comments
syscrusher commented
There's a memory leak the sample app in the README.
In the pinger func, defer res.Body.Close() doesn't execute because the function doesn't return because of the loop. I would just close it before sleeping. Not pretty, but just a sample app.
Thanks for the package. Simple API, stable, and extremely useful.
Ralph Caraveo commented
Thanks mucho for pointing that out...excellent catch!
Also, thanks for the kind words...i'm glad you find it useful. =)
syscrusher commented
Sorry, I misled you slightly. We still have to call Close within the if that checks whether res is not nil. Otherwise we might try to close something that's not even open.