Profile and monitor in real time
The heap profile report file <program>.hp is generated as the program executes, so it's perfectly fine to take a snapshot of the file at any time and visualize it with hp2ps, even if the program is still busy executing. Because very basic heap profiling (-hT) is possible without having compiled with profiling support, it is possible to produce running heap profiles with a very small overhead.
Increasing the sample interval -i to something relatively big, such as a couple of seconds, it is very feasible to extract heap profiles from long-running programs even in production environments.
A quick-and-dirty trick that isn't for the light-hearted is the -S Runtime System option. This option prints garbage collector statistics ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access