HotSpot JVM在JDK8取消了永久代(PermGen)代之元空间(Metaspace)的意义

J2EE 码拜 9年前 (2015-04-12) 1154次浏览 0个评论

网上搜了一些文章,完全不得要领。。 
感觉就是换了个名字的意思。。 
有没有哪位大神给简单介绍下,或者推荐一个网址,让我学习一下么?

HotSpot JVM在JDK8取消了永久代(PermGen)代之元空间(Metaspace)的意义
帮忙搜了一下,也没找到相关重点

http://blog.csdn.net/songuooo/article/details/7820030

http://singleant.iteye.com/blog/1308842

HotSpot JVM在JDK8取消了永久代(PermGen)代之元空间(Metaspace)的意义
最直接的后果,就是以后再也不会有outofmemoryerror permgen space这个错误了
HotSpot JVM在JDK8取消了永久代(PermGen)代之元空间(Metaspace)的意义
50分
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.
The Permanent Generation (PermGen) space has completely been removed and is kind of replaced by a new space called Metaspace. The consequences of the PermGen removal is that obviously the PermSize and MaxPermSize JVM arguments are ignored and you will never get a java.lang.OutOfMemoryError: PermGen error.

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
Metaspace Tuning

The maximum metaspace size can be set using the -XX:MaxMetaspaceSize flag, and the default is unlimited, which means that only your system memory is the limit. The -XX:MetaspaceSize tuning flag defines the initial size of metaspace If you don’t specify this flag, the Metaspace will dynamically re-size depending of the application demand at runtime.

Change enables other optimizations and features in the future

Application class data sharing
Young collection optimizations, G1 class unloading
Metadata size reductions and internal JVM footprint projects
There is improved GC performace also. More detail

http://stackoverflow.com/questions/18339707/permgen-elimination-in-jdk-8/22509753#22509753

HotSpot JVM在JDK8取消了永久代(PermGen)代之元空间(Metaspace)的意义
30分
只知道跟垃圾收集有关 http://openjdk.java.net/jeps/122
HotSpot JVM在JDK8取消了永久代(PermGen)代之元空间(Metaspace)的意义
啊。 谢谢楼上各位。 我先来仔细研读研读。。
HotSpot JVM在JDK8取消了永久代(PermGen)代之元空间(Metaspace)的意义
10分
哥们,我觉得这个最根本的好处就是在效率提升的同时增加了安全性。相对于C++来说,java语言更加安全,jvm具有自动的垃圾回收机制,而C++的程序员需要手动去清除垃圾。JVM这种设计思路确实使java语言的安全性提高了,并且不需要程序员手动去清理垃圾,但是带来了时间上的开销,也就导致了java语言效率低,速度相对慢。大部分实时系统比如股票实时显示系统智能用C或者C++来做,根本不能用java。基于jvm最初的设计,为了能在保证安全性的同时还能提高效率,最好的方式就是减少垃圾的产生,关闭String池就是从JDK7到JDK8的一个过渡,还有一些方式,总知思路就是减少产生垃圾的空间。纯属个人理解啊,紧供参考。
HotSpot JVM在JDK8取消了永久代(PermGen)代之元空间(Metaspace)的意义
谢谢各位。 虽然还没能全明白。 至少明白个大概。。 
HotSpot JVM在JDK8取消了永久代(PermGen)代之元空间(Metaspace)的意义
10分
permSize:原来的jar包及你自己项目的class存放的内存空间,这部分空间是固定的,启动参数里面-permSize确定,如果你的jar包很多,经常会遇到permSize溢出,且每个项目都会占用自己的permGen空间
改成metaSpaces,各个项目会共享同样的class内存空间,比如两个项目都用了fast-json开源包,在mentaSpaces里面只存一份class,提高内存利用率,且更利于垃圾回收
HotSpot JVM在JDK8取消了永久代(PermGen)代之元空间(Metaspace)的意义
引用 8 楼 qingyuan18 的回复:

permSize:原来的jar包及你自己项目的class存放的内存空间,这部分空间是固定的,启动参数里面-permSize确定,如果你的jar包很多,经常会遇到permSize溢出,且每个项目都会占用自己的permGen空间
改成metaSpaces,各个项目会共享同样的class内存空间,比如两个项目都用了fast-json开源包,在mentaSpaces里面只存一份class,提高内存利用率,且更利于垃圾回收

哎,可以共享类信息么? 这个我仿佛没有看到有地方这样说过。 能给个连接啥的么。。


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明HotSpot JVM在JDK8取消了永久代(PermGen)代之元空间(Metaspace)的意义
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!