JVM Architecture, Memory Areas - Yash-777/LearnJava GitHub Wiki

Overview

Thread States and Memory Areas:

A thread can be in only one state at a given point in time. These states are virtual machine states which do not reflect any operating system thread states [NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING, TERMINATED].

Java8 Update: PermGen is replaced with Metaspace which is very similar. Main difference is that Metaspace re-sizes dynamically i.e., It can expand at runtime. Java Metaspace space: unbounded (default)

The Heap is divided into young and old generations as follows : See

Memory Areas

Java Heap Memory is part of memory allocated to JVM by Operating System. Whenever we create objects they are created inside [heap in java][http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html].

Java Heap space is divided into three regions or generation for sake of garbage collection called Young Generation, Old or tenured Generation and Permanent Generation. Permanent generation is garbage collected during full gc in hotspot JVM

The Young Generation is where all new objects are allocated and aged. When the young generation fills up, this causes a minor garbage collection. A young generation full of dead objects is collected very quickly. Some surviving objects are aged and eventually move to the old generation.

The Old Generation is used to store long surviving objects. Typically, a threshold is set for young generation object and when that age is met, the object gets moved to the old generation. Eventually the old generation needs to be collected. This event is called a major garbage collection.

The Permanent generation contains metadata required by the JVM to describe the classes and methods used in the application. The permanent generation is populated by the JVM at runtime based on classes in use by the application.

PermGen has been replaced with Metaspace since Java 8 release. PermSize & MaxPermSize parameters will be ignored now. Have a look this [dzone article][https://dzone.com/articles/java-8-permgen-metaspace] by Pierre - Hugues Charbonneau to understand about Metaspace.

enter image description here

Image source:http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html

Refer to same article for more details.

JConsole

C:\Program Files\Java\jdk1.8.0_144\bin\jconsole.exe


As of Java 8, the PermGen space has been replaced with Metaspace.

http://stackoverflow.com/a/3849819/5081877