Daniele B
Daniele B

Reputation: 20412

Go(lang): How to use PPROF heap profile to find memory leaks?

I am trying to use pprof to verify memory leaks.

Can any explain how to read the heap profile that you find at: http://localhost:6060/debug/pprof/heap?debug=1

Also, is it normal that by typing the web command after starting go tool pprof http://localhost:6060/debug/pprof/heap it produces an empty .svg file?

Many Thanks

Upvotes: 7

Views: 12114

Answers (2)

Sjon
Sjon

Reputation: 5155

How to read the heap-profile is explained pretty good in this intel blogpost:

The numbers in the beginning of each entry ("1: 262144 [4: 376832]") represent number of currently live objects, amount of memory occupied by live objects, total number of allocations and amount of memory occupied by all allocations, respectively.

Upvotes: 1

alpe1
alpe1

Reputation: 340

I may help with the second question. You must provide the name of the binary to your command:

go tool pprof YOUR_COMPILED_BINARY http://localhost:6060/debug/pprof/heap

Upvotes: 3

Related Questions