Saturday, October 14, 2017

Killing of permgen in Java 8..!!

PermGen  in jdk7 --> Metaspace in jdk8

PermGen is replaced with Metaspace in Oracle/Sun JDK8, which is very similar. The main difference is that Metaspace can expand at runtime.

PermGen Size Limitations :-
  • Limited to MaxPermSize – default ~64M - 85M
  • Contiguous with Java Heap : Identifying young references from old gen and permgen would be more expensive and complicated with a non-contiguous heap – card table(A kind of remembered set that records where oops have changed in a generation).
  • Once exhausted throws OutOfMemoryError "PermGen space".
  • Application could clear references to cause class unloading.
  • Restart with larger MaxPermSize.
  • Size needed depends on number of classes, size of methods, size of constant pools.


Reasons of ignoring these argument is permanent generation has been removed in HotSpot for JDK8 because of following drawbacks
  • Fixed size at startup – difficult to tune.
  • Internal Hotspot types were Java objects : Could move with full GC, opaque, not strongly typed and hard to debug, needed meta-metadata.
  • Simplify full collections : Special iterators for metadata for each collector
  • Want to deallocate class data concurrently and not during GC pause
  • Enable future improvements that were limited by PermGen.
Advantages of MetaSpace :-
  • Take advantage of Java Language Specification property : Classes and associated metadata lifetimes match class loader’s
  • Per loader storage area – Metaspace
  • Linear allocation only
  • No individual reclamation (except for RedefineClasses and class loading failure)
  • No GC scan or compaction
  • No relocation for metaspace objects
Reference https://www.linkedin.com/pulse/killing-permgen-java-8-saral-saxena/

No comments:

Post a Comment