@author YHC
Some time ago did a project, Exception in thread "main" Java.lang.OutOfMemoryError:Java heap
This error occurs, so you need to find the reason, so use this tool, installation is more troublesome, posted out and share with you:
First step: Download Eclipse MAT
Download Address: http://www.eclipse.org/mat/downloads.php
The second step: after downloading the compressed package decompression, placed into the MyEclipse \myeclipse 9\dropins directory
after decompression, you will see these files: Correct one of the following typos is not "write" is "down"
The third step: according to the following figure, a,b,c the order of the corresponding file creation
Part fourth: Restart MyEclipse, open window->perferences, you will see this project:
To put it simply, use (console) if it is Tomcat or another server you need to find out how to configure JVM parameters:
Here is a program code that will cause Java.lang.OutOfMemoryError:Java heap space: (Very easy)
Package org.lx.test;
Import java.util.Date;
Import Java.util.HashMap;
Import Java.util.Map;
public class Outofmemorytest {public
static void Main (string[] args) {
map<integer,date> map=new hashmap& Lt;integer, date> ();
for (int i = 0; i < 600000000 i++) {
map.put (i, New Date ());}
}
First, some parameters need to be set before running:
Then on the page of the parameter settings, set the parameters in A,b order: (-xx:+heapdumponoutofmemoryerror) Avoid writing errors can be copy
The program code that runs the error will see the following results:
Then it generates a file java_pid3708.hprof, which is in the root directory of your project (MYECLIPSE10)
So then we'll open this file to analyze how to open the following figure: (Select the file you just generated in the project root java_pid3708.hprof Open)
When you open it, you will see that the following image is OK:
As for the question of how to find, please refer to the following connection:
The following article has been said in great detail:
1. Using Eclipse Memory Analyzer for heap dump file analysis
2. Using Mat for dump file analysis
If you have any questions, please correct me.