什么是JVM GC的大对象 [英] What is large object for JVM GC

查看:793
本文介绍了什么是JVM GC的大对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查理亨特说,他的演讲稿中的大型对象对JVM GC不利。 。因为:


  1. 大对象分配和初始化代价昂贵。

  2. >

如何定义大对象?>

大对象的大小不同会导致Java堆分页。我怎么知道对象是否是大对象?谢谢

解决方案

定义取决于平台,JVM和JVM配置。例如,这里是摘自 垃圾收集在三大JVM中的不同之处 由Michael Kopp发布: p> 大小对象



JRockit在
分配期间区分大对象和小对象。 对象被视为大的限制取决于JVM版本的
,堆大小,垃圾收集策略以及所用平台的
italics em> mine - DL)。它通常在2到128 KB之间。如果直接在旧代中生成
世代堆,大型
对象将分配在线程局部区域之外。当你开始思考这个问题时,这会让你感觉到很多
的感觉。年轻一代使用
副本收藏。在某些时候,复制一个对象比在垃圾收集中遍历它更贵


对于第二个问题,我我不确定如何获得该阈值,但特别是在HotSpot中,您可以设置它:



-XX:PretenureSizeThreshold = 2m



请参阅 热点JVM垃圾收集选项备忘单 由阿列克谢Ragozin关于此和许多其他许多的详细信息 - XX 选项。


Charlie Hunt says that large object is bad for JVM GC in his presentation. Because:

  1. Large objects are expensive to allocate and initialize.

  2. Large objects of different sizes can cause Java heap fregmentation.

How to define large object? How can I know if the object is large object? Thanks

解决方案

The definition depends on the platform, JVM and JVM configuration. For instance, here is as excerpt from How Garbage Collection differs in the three big JVMs blog post by Michael Kopp:

Large and small objects

The JRockit differentiates between large and small objects during allocation. The limit for when an object is considered large depends on the JVM version, the heap size, the garbage collection strategy and the platform used. (italics mine - DL.) It is usually somewhere between 2 and 128 KB. Large objects are allocated outside thread local area in in case of a generational heap directly in the old generation. This makes a lot of sense when you start thinking about it. The young generation uses a copy ccollection. At some point copying an object becomes more expensive than traversing it in ever garbage collection.

To your second question, I am not sure how to obtain that threshold, but specifically in HotSpot you can set it:

-XX:PretenureSizeThreshold=2m

Refer to the HotSpot JVM garbage collection options cheat sheet by Alexey Ragozin for details on this and many many other -XX options.

这篇关于什么是JVM GC的大对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆