I have an networking application in go, which I am trying to do memory profiling. I periodically generate pprof files by calling pprof.WriteHeapProfile(f), which generates a file mem1.pprof. Then I do:
go tool pprof -traces mem1.pprof > trace.out
part of the trace.out looks like this:
bytes: 10.89MB
10.89MB gin.mobius.com/mobi/storage.(*wireExecution).EnterBatchLimit
gin.mobius.com/mobi/storage.(*State).EnterBatchLimit
gin.mobius.com/mobi.(*Policy).EnterBatchNetReceiver
gin.mobius.com/mobi.(*Policy).netReceive
gin.mobius.com/mobi.(*Policy).RunningStep
gin.mobius.com/mobi.(*Policy).Execute
gin.mobius.com/mobi.(*Policy).StartRun.func1
-----------+-------------------------------------------------------
bytes: 5.45MB
5.45MB gin.mobius.com/mobi/storage.(*wireExecution).EnterBatchLimit
gin.mobius.com/mobi/storage.(*State).EnterBatchLimit
gin.mobius.com/mobi.(*Policy).EnterBatchNetReceiver
gin.mobius.com/mobi.(*Policy).netReceive
gin.mobius.com/mobi.(*Policy).RunningStep
gin.mobius.com/mobi.(*Policy).Execute
gin.mobius.com/mobi.(*Policy).StartRun.func1
-----------+-------------------------------------------------------
bytes: 704B
512.34kB gin.mobius.com/mobi/storage.(*wireExecution).EnterBatchLimit
gin.mobius.com/mobi/storage.(*State).EnterBatchLimit
gin.mobius.com/mobi.(*Policy).EnterBatchNetReceiver
gin.mobius.com/mobi.(*Policy).netReceive
gin.mobius.com/mobi.(*Policy).RunningStep
gin.mobius.com/mobi.(*Policy).Execute
gin.mobius.com/mobi.(*Policy).StartRun.func1
Please help me understand this output. I know there is only one goroutine with that callstack running.
- Then what do these repeated call stacks with different values for memory mean?
- When pprof.WriteHeapProfile() gets called if it is getting snapshot of heap memory being used at that time, how come there are multiple call stacks getting shown?