I am using list command in go tool pprof to analyse heap profile. On using the list command I am expecting to see lines in source that allocates specified amount of memory. This is how my result looks like.
(pprof) list getItems
Total: 259.09MB ROUTINE ======================== ddb.(*ItemDL).getEvents in /bld/src/my-repo/ddb/item_process_dl.go
0 322.15MB (flat, cum) 124.34% of Total
. . 201: ExpressionAttributeValues: expr.Values(),
. . 202: //Limit: aws.Int64(1000),
. . 203: }
. . 204: if nil != lastEvaluatedKey {
. . 205: params.SetExclusiveStartKey(lastEvaluatedKey)
. 163.08MB 206: }
//some more souce code
. . 266: LaunchTS: qItem.LaunchTS + svcparam.TimeToBumpUp,
. 21.01MB 267: }
Why are the values pointing to lines having no source code and just }
. How to interpret the above results ?
In the pprof
output you provided, the lines like }
with memory allocations are part of the function epilogue or prologue and may not be directly related to specific lines of your source code. The memory allocated there is often associated with bookkeeping or other tasks performed by the Go runtime during the function execution.
Here’s how to interpret the output:
Total
line shows the total amount of memory allocated by the function (322.15MB
in your example).ROUTINE ========================
line indicates the name of the function (ddb.(*ItemDL).getEvents
) and the source file where it’s located (/bld/src/my-repo/ddb/item_process_dl.go
).322.15MB (flat, cum) 124.34% of Total
: This line indicates that the function ddb.(*ItemDL).getEvents
is responsible for 322.15MB of memory allocations, and this accounts for 124.34% of the total memory allocations.163.08MB 206:
, provide a breakdown of memory allocations at specific lines of the function. For example, at line 206
, there is an allocation of 163.08MB
..
represent lines with no source code associated with them, such as closing braces }
or lines with compiler-generated code.206
is indented to show that it is within an if
block.flat
represents the amount of memory allocated within the function itself, and cum
represents the cumulative amount of memory allocated, including any functions it calls.206
), it indicates that memory is allocated at that line. The source lines with just }
or other symbols might indicate memory allocations not directly tied to specific lines of your source code.When interpreting memory profiles, it’s essential to focus on the areas of your code that contribute significantly to memory consumption. In some cases, memory allocations may occur in parts of the function not directly related to specific lines of your source code, such as function prologues and epilogues, which are generated by the Go runtime.