@Ian, This statement is a bit confusing to me regarding HeapInuse: "*which includes space allocated to hold objects that do not yet exist or that have been released by the garbage collector*"
According to memstats documentation, HeapInUse -> Includes all spans that have at least one object in them. So, why should it include space for objects that do not exist any more or that has been released by garbage collector. Should it not go to HeapIdle? (Or) Is it the case of internal fragmentation. For example, if a span is shared by 2 objects and one object is freed - then, the entire span is accounted under HeapInUse. But since there is free space in span, it can be used by new objects and it can not be returned to HeapIdle as there is one object in the span. When pprof runs, it only uses the live objects and therefore, it does not account for the free space in spans while HeapInUse will account for it. If this is the case, then how can we know the percentage of utilisation across a size class. Kindly clarify. Thanks, Varun On Wednesday, September 4, 2019 at 4:26:19 AM UTC+5:30 smal...@gmail.com wrote: > Got it,thanks > > > > 发自我的小米手机 > 在 Ian Lance Taylor <ia...@golang.org>,2019年9月3日 21:28写道: > > On Mon, Sep 2, 2019 at 11:01 PM Chao Yuepan <smal...@gmail.com> wrote: > > > > I have run a programas redis proxy which parses redis commands and > redirects to redis servers. > > > > I noticed it looks has memory leak issue. > > > > I use pprof to check the memory usage. It sows the total memory usage is > 856.02MB. I understand the value is memory usage in heap. > > > > > > > > > > > > If I check the runtime.memstats, it show the heapInUse is about 1.7GB. > > > > > > > > I use top to check RES of this program, it is 1.7G , it isthe same to > memstats.HeapInuse. > > > > > > I'm surprised why the total value in pprof is very different from the > real memory usage? (856.02MB vs 1.7G) > > > > And How can I figure out those usage in heap which are not displayed in > pprof? > > HeapInUse tells you the amount of system memory allocated to hold Go > objects, which includes space allocated to hold objects that do not > yet exist or that have been released by the garbage collector. pprof > tells you about live memory that is accessible by your program. With > the default GOGC value of 100, in a program in steady state, it's > normal for HeapInUse to be around twice as much as pprof memory, and > that is what you are seeing. > > Ian > > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ab89a6f9-b1a3-44a4-b9b6-ee5c32b676edn%40googlegroups.com.