java - connecting to jvm -


i want access jvm heap iterate on objects. found following example of how done. use jdk1.7.0_11.

i tried following code:

public static void main(string[] args) {     runtimemxbean runtimebean = managementfactory.getruntimemxbean();     system.out.println(runtimebean.getvmname());     system.out.println(runtimebean.getvmvendor());     system.out.println(runtimebean.getvmversion());     string jvmname = runtimebean.getname();     bugspotagent agent = new bugspotagent();     agent.attach(integer.parseint(jvmname.split("@")[0])); // exception here!!!!      vm.initialize(null, false);     vm vm = vm.getvm();      system.out.println(vm.getvminternalinfo());      objectheap heap = vm.getobjectheap();     heap.iterate(new customheapvisitor()); } 

there following output:

java hotspot(tm) 64-bit server vm oracle corporation 23.6-b04 

and exception:

   exception in thread "main" sun.jvm.hotspot.debugger.debuggerexception: windbg error: attachprocess failed!     @ sun.jvm.hotspot.debugger.windbg.windbgdebuggerlocal.attach0(native method)     @ sun.jvm.hotspot.debugger.windbg.windbgdebuggerlocal.attach(windbgdebuggerlocal.java:152)     @ sun.jvm.hotspot.bugspot.bugspotagent.attachdebugger(bugspotagent.java:789)     @ sun.jvm.hotspot.bugspot.bugspotagent.setupdebuggerwin32(bugspotagent.java:712)     @ sun.jvm.hotspot.bugspot.bugspotagent.setupdebugger(bugspotagent.java:515)     @ sun.jvm.hotspot.bugspot.bugspotagent.go(bugspotagent.java:492)     @ sun.jvm.hotspot.bugspot.bugspotagent.attach(bugspotagent.java:331)     @ mishanesterenko.jdi.main.main(main.java:27) 

what else should done make work? want access jvm object graph in heap , search graph.

agent.attach(integer.parseint(jvmname.split("@")[0])); // exception here!!!! 

about above, think should pass jvm process id, not current process id.

you remove line:

vm.initialize(null, false); 

so, can work fine.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -