1
jvm 힙에 액세스하여 객체를 반복하고 싶습니다. 나는 이것이 어떻게 행해질 수 있었는지에 따라 example을 발견했다. 나는 jdk1.7.0_11
을 사용한다.jvm에 연결
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());
}
출력이 다음입니다 : 나는 다음 코드를 시도
Java HotSpot(TM) 64-Bit Server VM
Oracle Corporation
23.6-b04
예외 :
Exception in thread "main" sun.jvm.hotspot.debugger.DebuggerException: Windbg Error: AttachProcess failed!
at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.attach0(Native Method)
at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.attach(WindbgDebuggerLocal.java:152)
at sun.jvm.hotspot.bugspot.BugSpotAgent.attachDebugger(BugSpotAgent.java:789)
at sun.jvm.hotspot.bugspot.BugSpotAgent.setupDebuggerWin32(BugSpotAgent.java:712)
at sun.jvm.hotspot.bugspot.BugSpotAgent.setupDebugger(BugSpotAgent.java:515)
at sun.jvm.hotspot.bugspot.BugSpotAgent.go(BugSpotAgent.java:492)
at sun.jvm.hotspot.bugspot.BugSpotAgent.attach(BugSpotAgent.java:331)
at mishanesterenko.jdi.Main.main(Main.java:27)
또 어떤 작품을 만들기 위해 수행해야? 마지막으로 힙에있는 jvm 객체 그래프에 액세스하여이 그래프를 검색하려고합니다.
작동 시키십니까? – Tupac
@Tupac, 꽤 오래 전에, 불행히도, 나는 일들이 어떻게 끝났는지 기억하지 못합니다. (아마 그냥 포기했을 것입니다. 당신은 user2994487의 대답을 볼 수 있습니다, 잘하면 당신을 도울 것입니다. –