How to find local variables in a heap file

I have a j2ee application and am tracking it using visualVM.

Let's say that I have a method like this:

public void doStuff(int param) { String s = getStringVariable(param); StringBuilder sb = new StringBuilder(); //Do stuff with sb object } 

From the tap thread, I see that some of my threads are stuck in the above method. So I created a heap dump file to figure out what s and sb contain.

But how can I do this? I am using Eclipse Memory Analyzer.

+6
source share
1 answer

you can get a local variable from your stream, because if the local variable is currently live, it means the only reference for this variable is its own stream .

So, first you need to list the current threads, and you can do this:

  • Click the object options button in the action bar [] .
  • Choose Java Basics → Browse Streams and Stacks.

Then, to list the object for a particular thread:

  • Right click -> List Object -> OutGoing Links

Then find your local variable with the <Java Local>

+11
source

All Articles