JDK8为何要废弃永久代

1、现实使用中易出问题。

  由于永久代内存经常不够用或者发生内存泄露,爆出异常 java.lang.OutOfMemoryError: PermGen 。

    字符串存在永久代中,容易出现性能问题和内存溢出。

    类及方法的信息等比较难确定其大小,因此对于永久代的大小指定比较困难,太小容易出现永久代溢出,太大则容易导致老年代溢出。

2、永久代会位GC带来不必要的复杂度,而且回收效率偏低。

3、Oracle可能会将HotSpot和JRockit合二为一。

参照 JEP122 :http://openjdk.java.net/jeps/122 ,原文截取:

Motivation

This is part of the JRockit and Hotspot convergence effort. JRockit customers do not need to configure the permanent generation (since JRockit does not have a permanent generation) and are accustomed to not configuring the permanent generation.

即:移除永久代是为融合 HotSpot JVM 与 JRockit VM 而做出的努力,因为 JRockit 没有永久代,不需要配置永久代。

原文地址:https://www.cnblogs.com/yangqiong1989/p/10665518.html