This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GCUtils { | |
private static final String DISABLE_EXPLICIT_GC = "DisableExplicitGC"; // need to be "manageable" in VM | |
public static void forceGC() { | |
String oldValue = HotSpotUtils.getVMOption(DISABLE_EXPLICIT_GC); | |
if ("true".equals(oldValue)) { | |
HotSpotUtils.setVMOption(DISABLE_EXPLICIT_GC, "false"); | |
System.gc(); | |
HotSpotUtils.setVMOption(DISABLE_EXPLICIT_GC, oldValue); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import sun.jvm.hotspot.memory.*; | |
import sun.jvm.hotspot.oops.*; | |
import sun.jvm.hotspot.debugger.*; | |
import sun.jvm.hotspot.runtime.*; | |
import sun.jvm.hotspot.tools.*; | |
import sun.jvm.hotspot.utilities.*; | |
public class DirectMemorySize extends Tool { |