Skip to content

net/http: memory leak #5314

Closed
Closed
@gpaul

Description

@gpaul
I'm seeing really weird GC behaviour when using the net/http package.

If I call a function that creates a bunch of garbage slices inside a ServeMux.HandleFunc
the issue rears its head. If I then also don't close the req.Body, the issue gets way
worse.

If I call the same function on its own, no memory is leaked. If I call the same function
in a goroutine and wait for it to finish, no memory is leaked either.

It seems like I'm doing something weird with net/http, or there's a bug lurking here.
I'm reporting this as I'm out of ideas.

go version:
go version devel +58f8a30f5b78 Tue Apr 16 14:20:06 2013 -0700 linux/amd64

uname -a:
Linux me 3.3.8-1.fc16.x86_64 #1 SMP Mon Jun 4 20:49:02 UTC 2012 x86_64 x86_64 x86_64
GNU/Linux

Code to reproduce is here:
http://play.golang.org/p/ALlr3_MzSX

$ GOGCTRACE=1 go run ram_issue.go | grep gc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions