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

a12939026 2014-09-03 08:43:02
网上搜了一些文章,完全不得要领。。
感觉就是换了个名字的意思。。
有没有哪位大神给简单介绍下,或者推荐一个网址,让我学习一下么?
...全文
1038 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
a12939026 2014-09-17
  • 打赏
  • 举报
回复
引用 8 楼 qingyuan18 的回复:
permSize:原来的jar包及你自己项目的class存放的内存空间,这部分空间是固定的,启动参数里面-permSize确定,如果你的jar包很多,经常会遇到permSize溢出,且每个项目都会占用自己的permGen空间 改成metaSpaces,各个项目会共享同样的class内存空间,比如两个项目都用了fast-json开源包,在mentaSpaces里面只存一份class,提高内存利用率,且更利于垃圾回收
哎,可以共享类信息么? 这个我仿佛没有看到有地方这样说过。 能给个连接啥的么。。
qingyuan18 2014-09-13
  • 打赏
  • 举报
回复
permSize:原来的jar包及你自己项目的class存放的内存空间,这部分空间是固定的,启动参数里面-permSize确定,如果你的jar包很多,经常会遇到permSize溢出,且每个项目都会占用自己的permGen空间 改成metaSpaces,各个项目会共享同样的class内存空间,比如两个项目都用了fast-json开源包,在mentaSpaces里面只存一份class,提高内存利用率,且更利于垃圾回收
a12939026 2014-09-13
  • 打赏
  • 举报
回复
谢谢各位。 虽然还没能全明白。 至少明白个大概。。
多木多多木 2014-09-09
  • 打赏
  • 举报
回复
哥们,我觉得这个最根本的好处就是在效率提升的同时增加了安全性。相对于C++来说,java语言更加安全,jvm具有自动的垃圾回收机制,而C++的程序员需要手动去清除垃圾。JVM这种设计思路确实使java语言的安全性提高了,并且不需要程序员手动去清理垃圾,但是带来了时间上的开销,也就导致了java语言效率低,速度相对慢。大部分实时系统比如股票实时显示系统智能用C或者C++来做,根本不能用java。基于jvm最初的设计,为了能在保证安全性的同时还能提高效率,最好的方式就是减少垃圾的产生,关闭String池就是从JDK7到JDK8的一个过渡,还有一些方式,总知思路就是减少产生垃圾的空间。纯属个人理解啊,紧供参考。
a12939026 2014-09-08
  • 打赏
  • 举报
回复
啊。 谢谢楼上各位。 我先来仔细研读研读。。
whos2002110 2014-09-04
  • 打赏
  • 举报
回复
只知道跟垃圾收集有关 http://openjdk.java.net/jeps/122
teemai 2014-09-04
  • 打赏
  • 举报
回复
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
霜之哀伤 2014-09-04
  • 打赏
  • 举报
回复
最直接的后果,就是以后再也不会有outofmemoryerror permgen space这个错误了
  • 打赏
  • 举报
回复

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧