Java Command Exports heap information for memory overflow (heapdumponoutofmemoryerror) (hprof file)

Source: Internet
Author: User

When there is a heapdumponoutofmemoryerror error, we need to analyze the reason, the following program is to simulate this error and export the dump file, so that you analyze

Gctest.java

 PackageGC; Public classGctest {Private Static Final int_1mb= 1024 * 1024;//approx. 1m               Public Static voidMain (string[] args) {//a total of about 8m, heap size set not more than 8388608B that is 8.388608m memory overflow, but need an integer, less than 8M will reproduce the error            byte[] A1, A2, A3, A4; A1=New byte[2 *_1MB]; A2=New byte[2 *_1MB]; A3=New byte[2 *_1MB]; A4=New byte[2 *_1MB]; }  }

This file is on the desktop, so do compile:

Execution Gctest.bat:

Set classpath=-xms10m-xmx10m-xmn2m-xx:survivorratio=8-xx:+heapdumponoutofmemoryerror-xx:heapdumppath=d : \study\log_hprof\gc.hprof-xx:+printgcdetails-xloggc:d:\study\log_gc\gc.log GC. Gctestpause

The results are as follows:

Gc.hprof file analysis with memory analysis tools such as Mat open (Jmap command combined with Mat plug-in analysis of memory leaks)

Java Command Exports heap information for memory overflow (heapdumponoutofmemoryerror) (hprof file)

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.