Evolution of Java Memory Architecture (Post Java 7.0)
- March 03, 2021
- 2339 Unique Views
- 3 min read
[About SKP's Core Java/Java EE Roots]
Java Memory Architecture (Pre Java 8.0)
Link to Part 1.
Pre-Java 7 Era (String Handling)
Java 7 Changes (String Handling)
2. String Interns are garbage collected like other Objects (based on reference count).
3. Set a higher number of Strings, even up to millions.
Java 8 Changes (String Handling)
- The default number of Strings in the _String Pool_ is now 60013, as compared to 1009
- At any point in time, you can check the _String Interning and Pooling_ usage statistics in the JVM by using -XX:+PrintStringTableStatistics (Symbol Table Statistics).
Java 8 Changes (PermGen to MetaSpace)
-
Eliminate or reduce Out of Memory: PermGen SpaceError. (PermGen is Gone) [PermGen elimination].
-
Memory for Class metadata is allocated only from native memory. Earlier, it was from the Contiguous Java Heap Memory. [MetaSpace Allocation].
-
Virtually unlimited (or very high) memory for Class metadata from native memory. [MetaSpace Allocation].
-
Limit the maximum limit for metadata in native memory using -XX:MaxMetaspaceSize [MetaSpace Configuration].
-
Garbage collection is triggered once the _MaxMetaspaceSize_ is reached [MetaSpace Garbage Collection].
-
PermGen and MetaSpace are not a direct movement. (Some items from _PermGen_ have been moved to _MetaSpace._ There are some miscellaneous items moved to the Heap Space, like _Interned Strings_) [PermGen MetaSpace, Heap Space Impact].
-
The earlier PermGen flags are ignored, like -XX:PermSize and -XX:MaxPermSize. If used, a warning is issued saying that these flags are no longer valid in Java 8. [PermGen Compiler Flags].
-
Once the _MaxMetaSpaceSize_ is reached, the Out of Memory: _MetaSpace Error_ is thrown. [MetaSpace Error].
-
The default _MetaSpaceSize_ on a 32-bit and 64-bit machines are 12MB and 16MB respectively. In contrast, the default _MaxPermSize_ was always set to 64MB. [MetaSpace Default Size].
-
The native memory size can be set by -XX:MaxDirectMemorySize. (The default is 128MB) [Native Memory or Direct Buffer Size].
-
MetaSpace usage is available from the verbose GC log using -XX:+PrintGCDetails [MetaSpace Statistics].
-
PermGen had a fixed size, but MetaSpace can Auto-Tune and Auto-Increase depending on the underlying OS. [MetaSpace Size Efficiency].
-
Classes can be de-allocated concurrently without GC pauses. It is more efficient than in PermGen, as that required frequent GC pauses. [MetaSpace Performance].
[Note]
Don’t Forget to Share This Post!
Comments (0)
No comments yet. Be the first.