java jvm 大对象,什么是JVM GC的大对象

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

Large objects are expensive to allocate and initialize.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值