Java in-Memory diagnostics

Source: Internet
Author: User

Java Memory Diagnostics is easy and requires:

1 Get heap Dump

2 Analysis Heap Dump

Get dump 1 VM arguments:-xx:+heapdumponoutofmemoryerror-xx:heapdumppath=./java_pid<pid>.hprof

Reference for VM options:http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

If not specified, the dump file is output to User.dir by default.

Java.lang.OutOfMemoryError:Java Heap Space
Dumping heap to java_pid8096.hprof ...
Heap dump file created [168062394 bytes in 1.306 secs]

Note that after you get the file, you can analyze it using the following command:

Jmap-histo./java_pid<pid>.hprof

Get dump 2 Jmap/jcmd

Jmap-dump:format=b,file=snapshot.jmap <pid>

Jcmd <process id/main class> gc.heap_dump filename=myheapdump

or direct access (histogram):

Jcmd <pid> Gc.class_histogram

Jmap-histo <pid>

Get dump 3 Jconsole + hotspotdiagnosticmxbean (install JDK)

Note that the files are stored under User.dir. (can be obtained with jinfo)

Analyze dump's jhat (requires JDK)

Referenc:

Http://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks.html#CIHGFAEG

Java in-Memory diagnostics

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.