Skip to content

Instantly share code, notes, and snippets.

@changyuefeng
changyuefeng / DirectMemorySize.java
Created March 21, 2017 02:10 — forked from rednaxelafx/DirectMemorySize.java
An Serviceability-Agent based tool to see stats of NIO direct memory, as an alternative on JDK6 without JMX support for direct memory monitoring. Only works on JDK6; to work on JDK7 will need some tweaking because static variables are moved to Java mirror
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 {
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #