Java process out-of-heap memory (off heap) size

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.