Java command export heapdumponoutofmemoryerror heap information (hprof file) jmap command combined with the mat plug-in to Analyze memory leakage

Source: Internet
Author: User

When a heapdumponoutofmemoryerror occurs, we need to analyze the cause.ProgramSimulate this error and export the dump file for analysis.

Gctest. Java

 Package  GC;  Public   Class  Gctest {  Private   Static   Final   Int _ 1 MB = 1024*1024 ; // About 1 m  Public   Static   Void Main (string [] ARGs ){
// The total size is about 8 MB, and the heap size cannot exceed 8388608b. That is, 8.388608m will cause memory overflow, but an integer is required. If it is less than 8 Mb, this error will be reproduced. Byte [] A1, A2, A3, A4; A1 = New Byte [2 * _ 1 MB]; A2 = New Byte [2 * _ 1 MB]; A3 = New Byte [2 * _ 1 MB]; A4 =New Byte [2 * _ 1 MB] ;}}

 

This file is on the desktop, So execute the compilation:

 

Run gctest. BAT:

 
Set classpath =C: \ Users \ Andy \ Desktop \ GC; Java-Xms10m-xmx10m-xmn2m-XX: Export vorratio = 8-XX: + export-XX: heapdumppath = D: \ gc_study \ log_hprof \ GC. hprof-XX: + printgcdetails-Xloggc: D: \ gc_study \ log_gc \ GC. Log GC. gctestpause

 

The result is as follows:

 

GC. hprof File Analysis with memory analysis tools such as mat open (jmap command combined with Mat plug-in analysis Memory leakage) Analysis

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.