See java heap contents at runtime

I am looking for a tool that allows me to see how objects are created on the heap at runtime. I used VisualVM-Profiles, but could not find when a variable of a certain type (the one I'm looking for) is being created. Maybe I'm something wrong ... I will also be grateful for any help on how to get such information using any API.

Regards, Marcin

+4
source share
3 answers

Typically, profilers (such as JProfiler ) will let you see this - see, for example, an explanation of the screencast distribution record .

However, they achieve this by attaching an agent to the JVM, which allows them to intercept low-level operations β€” this information is usually not available to users or Java programs. This way, you won’t be able to see the heap through JMX applications such as JConsole or JVisualVM.

+4
source

Inside VisualVM Profiler, select "Preferences" and specify the class that you want to profile. Maybe you also need to look at an option that writes distribution stacks.

+2
source

It looks like you are trying to debug a program and that using a debugger would be a better option. You must be able to add a conditional breakpoint to stop the program when the variable is assigned the value you are looking for. This will allow you to see all the values ​​at that time and the call stack to see what was called to create it.

+1
source

Source: https://habr.com/ru/post/1338835/


All Articles