Marcin Sanecki
Marcin Sanecki

Reputation: 1334

See the java heap content in run time

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

Upvotes: 5

Views: 2465

Answers (3)

Peter Lawrey
Peter Lawrey

Reputation: 533820

It sounds like you are trying to debug a program and that using the debugger would be the best option. You should be able to add a conditional breakpoint to stop the program when a 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.

Upvotes: 1

anergy
anergy

Reputation: 1384

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.

Upvotes: 2

Andrzej Doyle
Andrzej Doyle

Reputation: 103837

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.

Upvotes: 4

Related Questions