jconsole and java.lang.OutOfMemoryError
JConsole is a graphical monitoring tool to monitor Java Virtual Machine (JVM) and Java applications both on a local or remote machine.
The graphical console can be started using "jconsole" command in every "bin" location of JDK installation.
The documentation of how to use jconsole: The documentation of how to use jconsole:
Other such tools (used via CLI): https://github.com/patric-r/jvmtop
JVM and memory
Big applications with large code-base can quickly fill up the segment of the memory, which will cause java.lang.OutOfMemoryError which is related directly with Perm Gen (Permanent generation).Generally we can meet the way how is the Java memory pool divided at very interesting articles on these forums:
- https://stackoverflow.com/questions/1262328/how-is-the-java-memory-pool-divided
- https://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
- https://stackoverflow.com/questions/38330176/difference-between-xms-and-xmx-and-xxmaxpermsize
- https://www.journaldev.com/2856/java-jvm-memory-model-memory-management-in-java
- https://i.stack.imgur.com/uDdEk.png
https://www.optaplanner.org/blog/2015/07/31/WhatIsTheFastestGarbageCollectorInJava8.html
https://openjdk.java.net/jeps/291 (JEP 291: Deprecate the Concurrent Mark Sweep (CMS) Garbage Collector)
https://plumbr.io/handbook/garbage-collection-algorithms
https://stackify.com/java-performance-tools-8-types-tools-need-know/
https://blog.idrsolutions.com/2014/06/java-performance-tuning-tools/
https://dzone.com/articles/java-performance-troubleshooti-0
https://dzone.com/articles/top-9-free-java-process-monitoring-tools-amp-how-t
https://www.dnsstuff.com/jvm-performance
http://karunsubramanian.com/websphere/how-to-choose-the-correct-garbage-collector-java-generational-heap-and-garbage-collection-explained/
https://www.petefreitag.com/articles/gctuning/
http://javahonk.com/how-many-types-memory-areas-allocated-by-jvm/
https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/cms.html
https://codeahoy.com/2017/08/06/basics-of-java-garbage-collection/
https://dzone.com/articles/understanding-the-java-memory-model-and-the-garbag
http://all-about-java-and-weblogic-server.blogspot.com/2014/01/what-are-java-heap-young-old-and.html
http://blog.icodejava.com/tag/jvm-option-parameter-xxuseconcmarksweepgc/
Heap Memory Usage - Memory Pools:
Eden Space
Survivor Space
Tenured Gen
Non-Heap Memory Usage - Memory Pools:
Code Cache
Perm Gen
Heap memory
The heap memory is the runtime data area from which the Java VM allocates memory for all class instances and arrays. The heap may be of a fixed or variable size. The garbage collector is an automatic memory management system that reclaims heap memory for objects.
- Eden Space: The pool from which memory is initially allocated for most objects.
- Survivor Space: The pool containing objects that have survived the garbage collection of the Eden space.
- Tenured Generation or Old Gen: The pool containing objects that have existed for some time in the survivor space.
Non-heap memory
Non-heap memory includes a method area shared among all threads and memory required for the internal processing or optimization for the Java VM. It stores per-class structures such as a runtime constant pool, field and method data, and the code for methods and constructors. The method area is logically part of the heap but, depending on the implementation, a Java VM may not garbage collect or compact it. Like the heap memory, the method area may be of a fixed or variable size. The memory for the method area does not need to be contiguous.
- Permanent Generation: The pool containing all the reflective data of the virtual machine itself, such as class and method objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas.
- Code Cache: The HotSpot Java VM also includes a code cache, containing memory that is used for compilation and storage of native code.
Java objects reside in an area called the heap, while metadata such as class objects and method objects reside in the Permanent generation or Perm Gen area. The permanent generation is not part of the heap.
The heap is created when the JVM starts up and may increase or decrease in size while the application runs. When the heap becomes full, garbage is collected. During the garbage collection objects that are no longer used are cleared, thus making space for new objects.
-Xmssize Specifies the initial heap size.
-Xmxsize Specifies the maximum heap size.
-XX:MaxPermSize=size Sets the maximum permanent generation space size. This option was deprecated in JDK 8, and superseded by the -XX:MaxMetaspaceSize option.
Full specification of Java HotSpot VM Options are available at:- https://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
- https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html
- https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html
No comments:
Post a Comment