Friday, 2 February 2018

Memory Management In Java

https://www.cs.mun.ca/java-api-1.5/guide/management/jconsole.html

daemon threads - background threads

The HotSpot VM defines two generations: the young generation (sometimes called the "nursery") and the old generation. The young generation consists of an "eden space" and two "survivor spaces." The VM initially assigns all objects to the eden space, and most objects die there. When it performs a minor GC, the VM moves any remaining objects from the eden space to one of the survivor spaces. The VM moves objects that live long enough in the survivor spaces to the "tenured" space in the old generation. When the tenured generation fills up, there is a full GC that is often much slower because it involves all live objects. The permanent generation holds all the reflective data of the virtual machine itself, such as class and method objects.

The memory pools available depend on the JVM being used. For the HotSpot JVM, the pools are:

Eden Space (heap): pool from which memory is initially allocated for most objects.
Survivor Space (heap): pool containing objects that have survived GC of eden space.
Tenured Generation (heap): pool containing objects that have existed for some time in the survivor space.
Permanent Generation (non-heap): holds all the reflective data of the virtual machine itself, such as class and method objects. With JVMs that use class data sharing, this generation is divided into read-only and read-write areas.
Code Cache (non-heap): HotSpot JVM also includes a "code cache" containing memory used for compilation and storage of native code.

No comments: