开发者

Is it possble to get all objects from memory?

开发者 https://www.devze.com 2022-12-15 20:59 出处:网络
How to get all objects present in memory? public static void mai开发者_StackOverflow中文版n( String[] arg ){

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

精彩评论

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