Search code examples
javamemory-managementmemory-leaksjava-8permgen

Java8 has completely removed permgen space from it's memory area. will it completely stop memory leak issues ? ...


This is what I have got from oracle site:

Area: HotSpot / gc

Synopsis

The command line flags PermSize and MaxPermSize have been removed and are 
ignored. If used on the command line a warning will be emitted for each.

Java HotSpot(TM) Server VM warning: ignoring option PermSize=32m; support 
was removed in 8.0
Java HotSpot(TM) Server VM warning: ignoring option MaxPermSize=128m;
support was removed in 8.0

Nature of Incompatibility

source

Solution

  • No. Of course memory leaks are still possible. Actually most of memory leaks appear in normal heap, not in permgen/metaspace, so this change don't affect them. For example, one may create a HashMap in static field and gradually fill it without removing elements. This way heap consumption will constantly grow.

    Also moving class data from permgen to metaspace doesn't mean that it does not require space. It's just allocated in off-heap region and can be controlled via MaxMetaspaceSize option (infinity by default). This change is mostly internal (makes some things in JVM easier) and does not affect normal programmers. The only visible problem it solves is that with default setting you will now unlikely to have problems when too many classes are loaded. But this will not help you if you have a significant class loader leak: you are still limited by physical memory and swap size on your machine.