How can I find the local variables in Heap file

柔情痞子 提交于 2019-12-23 08:50:50

问题


I have a j2ee application and monitoring it by visualVM.

Lets 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 thread tap, I can see that some of my threads stuck in the above method. So I have generated a heap dump file to figure out what is s and sb contains.

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


回答1:


you can get the local variable's from your thread, because if a local variable is a currently a live, then that means the only reference for that variable is its own thread.

So first you need to list your current threads, and you can do that by:

  1. Click on the objects options button from the actions bar

    .
  2. Select Java Basics -> Threads Overview and Stacks.

Then to list the object for a specific Thread:

  • Right Click -> List Object -> OutGoing references

Then Search for your local variable with in a tag <Java Local>



来源:https://stackoverflow.com/questions/22491527/how-can-i-find-the-local-variables-in-heap-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!