One, the off heap memory size allocated with Bytebuffer.allocatedirect native process
Install the Mbeans plugin in JVISUALVM, and then view the Java.nio/bufferpool/direct
In-Process use code acquisition
new ObjectName("java.nio:type=BufferPool,name=direct" ) ;MBeanInfo info = mbs.getMBeanInfo(objectName) ;for(MBeanAttributeInfo i : info.getAttributes()) { ":" + mbs.getAttribute(objectName , i.getName()));}
Remote process
- JMX Access
If the target machine does not start JMX, then add the JVM parameters:
-Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremotAe.ssl=false
Restart process
This machine is then accessed via a JMX connection:
String Jmxurl ="Service:jmx:rmi:///jndi/rmi://10.125.6.204:9999/jmxrmi"; Jmxserviceurl serviceurl =NewJmxserviceurl (Jmxurl); Map map =NewHashMap (); String[] Credentials =NewString[] {"Monitorrole","QED"}; Map.put ("Jmx.remote.credentials", credentials); Jmxconnector connector = jmxconnectorfactory. Connect (serviceurl, map); Mbeanserverconnection mbsc = Connector.getmbeanserverconnection (); ObjectName ObjectName =NewObjectName ("Java.nio:type=bufferpool,name=direct") ; Mbeaninfo mbinfo = Mbsc.getmbeaninfo (objectName); for(Mbeanattributeinfo i:mbinfo.getattributes ()) {System.out. println (I.getname () +":"+ Mbsc.getattribute (ObjectName, I.getname ()));}
Second, using unsafe reflection calls directly requested out of the heap memory
Java is not available, requires tools like Gperftools to view, next summary
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java process out-of-heap memory (off heap) size