Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

See the java heap content in run time

Tags:

java

memory

jvm

I am looking for any tool that allows me to see how objects are created on heap in run time. I was using VisualVM - Profiles but was not able to find when a variable of specific type (the one I am looking for) is being created. Maybe I do something wrong... I will be also thankful getting any hint how to get such information using any API.

Regards, Marcin

like image 537
Marcin Sanecki Avatar asked Feb 08 '11 11:02

Marcin Sanecki


2 Answers

Typically, profilers (such as JProfiler) will allow you to see this - see for example the Allocation recording explained screencast.

However, they achieve this by attaching an agent to the JVM that allows them to intercept the low-level operations - this information is not usually available to either users or Java programs. As such, you won't be able to see the heap via JMX apps such as JConsole or JVisualVM.

like image 78
Andrzej Doyle Avatar answered Sep 22 '22 12:09

Andrzej Doyle


Inside VisualVM Profiler, select the Settings and specify the class you want to profile. May be you also need to look on the option which record allocation stacks.

like image 24
anergy Avatar answered Sep 21 '22 12:09

anergy