GoogleCodeExporter
``` vmInfoList and vmMap in com.jvmtop.view.VMOverviewView are add in when new jvm process created, but never cleaned even if the jvm process is dead(detached), this may caused memory leak. A possible fix: diff --git a/jvmtop/src/com/jvmtop/view/VMOverviewView.java b/jvmtop/src/com/jvmtop/view/VMOverviewView.java index c4ada39..4dfa89c 100644 --- a/jvmtop/src/com/jvmtop/view/VMOverviewView.java +++ b/jvmtop/src/com/jvmtop/view/VMOverviewView.java @@ -23,6 +23,7 @@ package com.jvmtop.view; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -82,6 +83,23 @@ public class VMOverviewView extends AbstractConsoleView "%5d %-15.15s [ERROR: Connection refused/access denied] %n", vmInfo.getId(), getEntryPointClass(vmInfo.getDisplayName())); } + else if (vmInfo.getState() == VMInfoState.DETACHED) { + System.out.printf("%5d %-15.15s [ERROR: Detached, will remove it from list] %n", + vmInfo.getId(), getEntryPointClass(vmInfo.getDisplayName())); + + // remove from vmMap + vmMap.remove(vmInfo.getId()); + } + + // remove from vmInfoList + Iterator<VMInfo> it = vmInfoList.iterator(); + while(it.hasNext()){ + Integer vmid = it.next().getId(); + + if(vmMap.containsKey(vmid)){ + vmInfoList.remove(it); + } + } } } ``` Original issue reported on code.google.com by `[email protected]` on 24 Jul 2014 at 11:41