You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a daemon for collecting and analyzing http requests -
https://github.com/antage/cdnstats
After few days it is running in production I notice a memory leak.
As I imported net/http/pprof already I've digged in pprof reports.
(pprof) top
Total: 318.5 MB
152.0 47.7% 47.7% 152.0 47.7% net/textproto.(*Reader).ReadLine
140.5 44.1% 91.8% 140.5 44.1% string_table.(*StringTable).Store
15.5 4.9% 96.7% 156.0 49.0% main.update
6.5 2.0% 98.7% 6.5 2.0% main.postProcess
3.5 1.1% 99.8% 3.5 1.1% net/textproto.(*Reader).ReadMIMEHeader
0.5 0.2% 100.0% 0.5 0.2% main.main
0.0 0.0% 100.0% 155.5 48.8% net/http.(*conn).readRequest
0.0 0.0% 100.0% 155.5 48.8% net/http.(*conn).serve
0.0 0.0% 100.0% 155.5 48.8% net/http.ReadRequest
0.0 0.0% 100.0% 0.5 0.2% runtime.main
I think 152mb in net/textproto.(*Reader).ReadLine is a memory leak.
Attached graph from pprof shows that source of the memory leak is net/http module.
I don't stop the daemon so I can provide any additional information.
Which compiler are you using (5g, 6g, 8g, gccgo)? - 6g
Which operating system are you using? - Debian 6.0 amd64
Which version are you using? (run 'go version') - go version go1.0.2
I looked at your code. It doesn't look like you close the http.Response Body anywhere,
as is documented. So you're probably also "leaking" file descriptors with the TCP
connections held open forever, which means you're also not re-using TCP connections.
by antage:
Attachments:
The text was updated successfully, but these errors were encountered: