jvm virtual machine (a): jvm memory overflow problem analysis and solution

  Learn about the java virtual machine, one of the

added operating parameters
-XX: + HeapDumpOnOutOfMemoryError -Xms30m -Xmx30m

-XX: + HeapDumpOnOutOfMemoryError this parameter will generate a stack snapshot for locating abnormal

Simulation scenario memory overflow, simple code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package top.alertcode.demo.jvm;

import java.util.ArrayList;


* @author alertcode
* @date 2018-04-03
* @copyright alertcode.top
*/
public class {


* This code eventually run out of memory exception occurs
* @param args
* / public static void main (String [] args) { the ArrayList <OutOfMemoryDemo> List = new new the ArrayList <OutOfMemoryDemo> (); the while ( to true ) { List. the Add ( new new OutOfMemoryDemo ()); } } the following error occurs // / * the target Connected to the VM, address: '127.0.0.1:53483', Transport: 'Socket' Exception in Thread "main" a java.lang.OutOfMemoryError : the Java heap Space AT java.util.Arrays.copyOf (Arrays.java:3210) AT java.util.Arrays.copyOf (Arrays.java:3181)











at java.util.ArrayList.grow(ArrayList.java:265)
at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:239)
at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:231)
at java.util.ArrayList.add(ArrayList.java:462)
at top.alertcode.demo.jvm.OutOfMemoryDemo.main(OutOfMemoryDemo.java:15)
Disconnected from the target VM, address: '127.0.0.1:53483', transport: 'socket'*/
}

  Use analysis tools MAT (Eclipse Memory Analyzer), were analyzed, it is easy to locate the cause of memory leaks that frequently create objects. Referring next to FIG:
img

Original: Big Box  jvm virtual machine (a): analysis and problem solving jvm memory overflow


Guess you like

Origin www.cnblogs.com/wangziqiang123/p/11618285.html