开发者

Is it possble to get all objects from memory?

How to get all objects present in memory?

public static void mai开发者_StackOverflow中文版n( String[] arg ){
    MyClass object1 = new MyClass();
    BigDecimal bd = new BigDecimal();
    Object obj = new Object();
    List allObjects = getAllObjects(); // return  object1, bd, obj        
    ;
    ;
    ;  

}


Probably the easiest is getting a heap dump by VisualVM. JDK also includes related tools, as the jmap tool.


I fear there is no easy answer to do this during runtime, either you use Instrumentation How can I access Java heap objects without a reference? or write an agent http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜