On Tue, May 25, 2021 at 6:53 AM varun...@gmail.com <varun.1...@gmail.com> wrote: > > 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?
A typical span can contain a large number of objects. Each one of those objects may be allocated or not. If a span contains at least one allocated object, the total size of the span will be counted as part of HeapInUse. > 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. Yes. > If this is the case, then how can we know the percentage of utilisation > across a size class. That seems like a different question. But you can find the answer to that question by looking at the BySize array. 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/CAOyqgcUfXpiN69rc8yoFo-%3DmCpA9Ff0XeoHcYu-3UYqp7KY5Rw%40mail.gmail.com.