What is the difference between PermGen and Metaspace?

前端 未结 3 1849
醉梦人生
醉梦人生 2020-11-28 17:43

Until Java 7 there was an area in JVM memory called PermGen, where JVM used to keep its classes. In Java 8 it was removed and replaced by area called

3条回答
  •  再見小時候
    2020-11-28 18:12

    Bye, Bye PermGen, Hello Metaspace

    PermGen has been completely removed.

    Metaspace garbage collection - Garbage collection of the dead classes and classloaders is triggered once the class metadata usage reaches the MaxMetaspaceSize.

    The space Metadata was held is no longer contiguous to the Java heap, The metadata has now moved to native memory to an area known as the Metaspace.

    In Simple words,

    Since the class metadata is allocated out of native memory, the max available space is the total available system memory. Thus, you will no longer encounter OOM errors and could end up spilling into the swap space.

    The removal of PermGen doesn’t mean that your class loader leak issues are gone. So, yes, you will still have to monitor your consumption and plan accordingly, since a leak would end up consuming your entire native memory.

    Some other articles, with analysis: Link1, Link2 , and this

提交回复
热议问题