JVM Memory Model

Java Memory Model 



Heap : Used for allocating new objects and Java Runtime classes.

Minor GC : When Eden Space ( in Young generation ) is filled, garbage collection happens, it deletes the objects not referenced, it moves the longer living objects to Surviving spaces and even longer aged objects( beyond a threshold) to Old Generation.

All the Garbage Collection events are "Stop The World" events, means all the threads stop when GC thread runs. Minor GCs are fast and not noticebale but major GC events can be clearly noticeable and even cause apps to unresponsive during that time.

When JVM falls short of stack space, it throws StackOverFlowError and when it runs out of heap space, it throws OutOfMemoryError.

Interned Strings are kept in a Hashtable in Permanent Generation.  Interned strings are the string literals appearing explicitly in code or created by explicitly calling intern() method on String object.    ("j"+"v"+"m").intern()=="jvm"

jstat, jvisualvm - tools for looking into jvm process memory usage. 
javap - tool for looking into class bytecode ( .class)

References:

http://tutorials.jenkov.com/java-concurrency/java-memory-model.html
http://blog.jamesdbloom.com/JVMInternals.html
https://www.journaldev.com/4098/java-heap-space-vs-stack-memory
https://www.journaldev.com/2856/java-jvm-memory-model-memory-management-in-java


Comments

Popular posts from this blog

SQL

Analytics

DBeaver