Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in net/http #3792

Closed
gopherbot opened this issue Jul 2, 2012 · 1 comment
Closed

Memory leak in net/http #3792

gopherbot opened this issue Jul 2, 2012 · 1 comment

Comments

@gopherbot
Copy link
Contributor

by antage:

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

Attachments:

  1. pprof10109.0.ps (11723 bytes)
@bradfitz
Copy link
Contributor

bradfitz commented Jul 2, 2012

Comment 1:

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.

Status changed to Invalid.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants