So after some further debugging it seems that after a call to
FreeOSMemory() this part of the profile disappears.

So my theory is that this span of memory was just not returned to the OS by
the scavenger because parts of it were being reused by other allocations.
I'm not 100% certain on the details of how the memory allocator and
scavenger work, but based on my understanding the scavenger returns spans
to the OS
roughly every 5 minutes if they are completely unused. However parts of a
span can be reused by the runtime for other allocations.

That would explain this behaviour.

Can anyone confirm my theory, or give another explanation?
On Monday, September 29, 2014 1:57:39 PM UTC-7, Kamil Kisiel wrote:


I'm trying to figure out what looks like a strange memory allocation
problem in one of our applications.
It seems that for some reason which I can't determine the memory allocated
by gob.Encoder's internal byte slice is not being freed, or at least that's
what the profile seems to indicate.

Here's a link to a portion of the relevant pprof diagram with


The source of the original Encode() call is from Save() method from the
go-cache package:


I confirmed that the method finished running and is not blocked, and the
invocation only happens once on startup of the application. At the point
this heap dump was taken it had already
been running for a number of days...

So my question is why does it seem like this memory is still in use?

This is with go1.3 on Linux/amd64

- K
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
groupgolang-nuts @
postedSep 29, '14 at 8:57p
activeSep 30, '14 at 3:45p

1 user in discussion

Kamil Kisiel: 2 posts



site design / logo © 2021 Grokbase