OutOfMemoryError
When I ran my application, it threw the following exceptions:
- java.lang.OutOfMemoryError: GC overhead limit exceeded[7,9,15]
- java.lang.OutOfMemoryError: Java heap space
- System.gc();
- Add the following Java Options
- -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
- System will generate a
gc.logfile
- System will generate a
- -XX:+HeapDumpOnOutOfMemoryError
- System will generate a heap dump file
- There is an additional HotSpot VM command line option that allows a user to specify a path where the heap dump will be placed
- -XX:HeapDumpPath=
- -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
- Analyze the log files:
- Use regular text editor to examine
gc.logfile - Use Eclipse Memory Analyzer to examine heap dump file (i.e., java_xxx.hprof)
- Use regular text editor to examine
JVM Options
The command line options specify:
-XX:+PrintGCDetails- prints more details at garbage collection.
-XX:+PrintGCTimeStamps- prints a time stamp representing the number of seconds since the HotSpot VM was launched until the garbage collection occurred.
-Xloggc:gc.log- causes information about the heap and garbage collection to be printed at each collection.
To set
Java Options in JDeveloper, do the following:- Right select your project (i.e.,
ViewController) and bring up the context menu - Select Project Properties...
- Select Run/Debug/Profile
- Select your Run Configuration (i.e.,
Default) - Click Edit button
- Specify
-Xloggc:gc.log -XX:-PrintGCDetailsin the Java Options field
gc.log will be generated. I've found mine in the following default location:- .../system11.1.1.5.37.60.13/DefaultDomain
gc.log, read [5,15] for details.However,
gc.log file was not really helpful because it simply pointed out there was a heap issue. But, it didn't say where.The next step I have taken is running my server with the following flag:
-XX:+HeapDumpOnOutOfMemoryError
it generated a
java_pid30835.hprof file when my server encountered a heap error.Eclipse Memory Analyzer
The heap dump file (i.e.,
java_pid30835.hprof) is generated by HPROF—a heap and cpu profiling tool. My heap dump file was generated in binary format. Therefore I need to use Eclpse Memory Analyzer to examine it.You can install Eclipse MAT via the Eclipse Update manager . Select "General Purpose Tools " and install "Memory Analyser (Incubation)" and "Memory Analyser (Charts)".
Heap Size Adjustment
If you observe an OutOfMemoryError in the garbage collection logs, try increasing the Java heap size to 80% of the physical memory you have available for the JVM. Based on whether the old generation space or the permanent generation space is running out of memory, you adjust the sizes of heap spaces in this way[10]:
- For old generation space OutOfMemoryErrors
- increase -Xms and -Xmx
- For permanent generation OutOfMemoryErrors
- increase -XX:PermSize and -XX:MaxPermSize
References
- Eclipse Update Manager
- Eclipse Memory Analyzer
- Java Hotspot VM Options
- Integrated WebLogic Server (WLS)
- Diagnosing a Garbage Collection problem
- Frequently Asked Questions about Garbage Collection
- GC Overhead Limit Exceeded
- HPROF: A Heap/CPU Profiling Tool in J2SE 5.0
- Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning
- Java Performance by Charlie Hunt and Binu John
- Understanding Garbage Collection
- Java HotSpot VM Options
- GCViewer (a free open source tool)
- Understanding Garbage Collector Output of Hotspot VM
- A Case Study of java.lang.OutOfMemoryError: GC overhead limit exceeded
- Memory Analyzer Downloads
- The stand-alone Memory Analyzer is based on Eclipse RCP.
3 comments:
Excellent post as usual!!! Thorough, analytic but not boring :)
Are there any advantages in using
Eclipse Memory Analyzer instead of Java VisualVM (http://sdoulger.blogspot.com/2011/03/jvisualvm-aka-java-visualvm.html)?
>Eclipse Memory Analyzer vs. Java VisualVM
I would say there is not any advantages in using MAT instead of Java VisualVM. It's just personal preference (i.e., familiarity with Eclipse).
I tend to disagree (ok I'm biased ;-) ), but the Eclipse Memory Analyzer is still (after VisualVM "copied" some features) much more feature rich and also faster for large heap dumps.
Regards,
Markus
Post a Comment