Understanding Java Memory Model
Understanding Java Memory Model is an essential learning for serious Java developers who develop, deploy, monitor, test, and tune performance of a Java application. In this blog post, we are going to discuss on Java memory model and how each part of JVM memory contributes to run our programs.
First of all, check whether you understand the following diagram of JVM architecture. If you are not familiar with it, I highly suggest you to skim through my previous post (“Java Ecosystem (Part 1): Understanding JVM Architecture“) and refresh your knowledge.
JVM Memory Model
You must have used some of the following JVM memory configurations when running resource-intensive Java programs.
- -XmsSetting — initial Heap size
- -XmxSetting — maximum Heap size
- -XX:NewSizeSetting — new generation heap size
- -XX:MaxNewSizeSetting — maximum New generation heap size
- -XX:MaxPermGenSetting — maximum size of Permanent generation
- -XX:SurvivorRatioSetting — new heap size ratios (e.g. if Young Gen size is 10m and memory switch is –XX:SurvivorRatio=2, then 5m will be reserved for Eden space and 2.5m each for both Survivor spaces, default value = 8)
- -XX:NewRatio — providing ratio of…