I am running into various issues running a Java program on a c3.large Amazon EC2 ubuntu machine with 2CPU and 3.75GB memory (https://aws.amazon.com/ec2/instance-types/).
Right now I am running with the java -Xmx3750m flag. I have tried several different values for several flags, including PermSize, MaxPermSize, -Xmn, -Xmx, -Xms, NewRatio, etc, resulting in various different problems. Maybe I am overlooking something obvious, or maybe the c3.large instance just doesn't have enough memory for some of my runs.
My jobs sometimes complete with no issue, and other times run into one of the following issues:
1) Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
2) OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000007e7a80000, 122683392, 0) failed; error='Cannot allocate memory' (errno=12) There is insufficient memory for the Java Runtime Environment to continue. Native memory allocation (malloc) failed to allocate 122683392 bytes for committing reserved memory. An error report file with more information is saved as:
I also tried some of the verbose gc flags, and saw the following in one of the runs:
[Full GC [PSYoungGen: 6123K->0K(12288K)] [ParOldGen: 2542552K->2546337K(2560000K)] 2548675K->2546337K(2572288K) [PSPermGen: 5555K->5555K( 21504K)], 5.1085130 secs] [Times: user=10.06 sys=0.04, real=5.10 secs] [GC [PSYoungGen: 6131K->6123K(191488K)] 2552469K->2552461K(2751488K), 0.0144180 secs] [Times: user=0.01 sys=0.01, real=0.02 secs] [Full GC [PSYoungGen: 6123K->0K(191488K)] [ParOldGen: 2546337K->2552429K(2560000K)] 2552461K->2552429K(2751488K) [PSPermGen: 5555K->5555K (21504K)], 6.4821310 secs] [Times: user=12.72 sys=0.07, real=6.48 secs] [GC [PSYoungGen: 7147K->7139K(14336K)] 2559577K->2559569K(2574336K), 0.0135490 secs] [Times: user=0.02 sys=0.00, real=0.02 secs] [Full GC [PSYoungGen: 7139K->0K(14336K)] [ParOldGen: 2552429K->2559569K(2560000K)] 2559569K->2559569K(2574336K) [PSPermGen: 5555K->5555K( 21504K)], 4.8677750 secs] [Times: user=9.65 sys=0.04, real=4.86 secs] [Full GC [PSYoungGen: 7147K->7139K(14336K)] [ParOldGen: 2559569K->2559569K(2560000K)] 2566717K->2566709K(2574336K) [PSPermGen: 5555K->555 5K(21504K)], 4.8541370 secs] [Times: user=9.63 sys=0.03, real=4.85 secs] [Full GC [PSYoungGen: 7139K->7139K(14336K)] [ParOldGen: 2559975K->2559975K(2560000K)] 2567115K->2567115K(2574336K) [PSPermGen: 5555K->555 5K(21504K)], 4.8919580 secs] [Times: user=9.70 sys=0.04, real=4.89 secs] [Full GC [PSYoungGen: 7139K->7139K(14336K)] [ParOldGen: 2559975K->2559934K(2560000K)] 2567115K->2567074K(2574336K) [PSPermGen: 5555K->555 5K(21504K)], 6.4815400 secs] [Times: user=12.72 sys=0.06, real=6.49 secs] [Full GC [PSYoungGen: 7139K->7139K(14336K)] [ParOldGen: 2559992K->2559992K(2560000K)] 2567132K->2567132K(2574336K) [PSPermGen: 5555K->555 5K(21504K)], 4.8964570 secs] [Times: user=9.71 sys=0.04, real=4.89 secs] [Full GC [PSYoungGen: 7139K->7139K(14336K)] [ParOldGen: 2559992K->2559992K(2560000K)] 2567132K->2567132K(2574336K) [PSPermGen: 5555K->555 5K(21504K)], 4.8817790 secs] [Times: user=9.69 sys=0.03, real=4.89 secs] Heap PSYoungGen total 14336K, used 7168K [0x00000007b1e00000, 0x00000007c9100000, 0x0000000800000000) eden space 7168K, 100% used [0x00000007b1e00000,0x00000007b2500000,0x00000007b2500000) from space 7168K, 0% used [0x00000007b2500000,0x00000007b2500000,0x00000007b2c00000) to space 185856K, 0% used [0x00000007bdb80000,0x00000007bdb80000,0x00000007c9100000) ParOldGen total 2560000K, used 2559992K [0x0000000715a00000, 0x00000007b1e00000, 0x00000007b1e00000) object space 2560000K, 99% used [0x0000000715a00000,0x00000007b1dfe120,0x00000007b1e00000) PSPermGen total 21504K, used 5590K [0x000000070b400000, 0x000000070c900000, 0x0000000715a00000) object space 21504K, 25% used [0x000000070b400000,0x000000070b9758b8,0x000000070c900000)