Hi, folks,

I'm trying to track down a memory leak in a web server application, and I'm
having a hard time making sense of the output of the heap dumps emitted by
the net/http/pprof handlers.  One of the dumps starts with:

heap profile: 5: 192080 [47408: 90679856] @ heap/1048576
1: 155648 [1: 155648] @ 0x583a0f ...
1: 32768 [1: 32768] @ 0x6f2aab ...
1: 2048 [1: 2048] @ 0x5b47ff ...

If I understand this correctly, there are 5 in-use objects on the heap,
taking up 192kB, and 47,408 allocated objects taking up 90MB.  And then
there is a line and a stack trace for each one of those 47,408, showing
where it was allocated.

Already this seems unbelievable:  I can't imagine a web server that's been
running for days could possibly only have 5 heap objects that are in use.
Perhaps I'm misunderstanding what "in use" means...

But where it really gets crazy is the comparison with the runtime.MemStats
at the bottom:
# Alloc = 5812304
# Sys = 20642040
# HeapAlloc = 5812304
# HeapSys = 12877824
# HeapIdle = 5267456
# HeapInuse = 7610368
# HeapReleased = 0
# HeapObjects = 54025
# Stack = 1146880 / 1146880
# MSpan = 95608 / 163840
# MCache = 7200 / 16384
# BuckHashSys = 4371655
# GCSys = 796672
# OtherSys = 1268785
# NextGC = 9006400
# NumGC = 14832

So, this says there's only 5.8MB allocated, where the top part said 90MB.
This says there are 7.6MB in use on the heap, where the top part said
192kB.  This says there are 54k objects on the heap, where the top part
said 47k.

I'm totally flummoxed at understanding these numbers, and particularly how
they correlate to the object list in the top part of the output.  I'd
greatly appreciate explanations, or pointers to same.

My real goal, BTW, is to compare two of these dumps, taken 12 hours apart,
and try to figure out where my memory is leaking.  But I can't be confident
of doing that when I clearly don't understand how to interpret the
numbers.  If the top half is correct and only 5 of my objects are in use, I
may not have a real memory leak at all — but in that case, why does
HeapAlloc keep growing?

Many thanks in advance...
Steve

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to