minimum heap size for ibm jvm

When you have established the maximum heap size that you need, you might want to set the minimum heap size to the same value; for example, -Xms 512M -Xmx 512M. Using the same values is not usually a good idea, because it delays the start of garbage collection until the heap is full. The first time that the Garbage Collector runs, therefore, becomes a very expensive operation. Also, the heap is most likely to be very fragmented when a need to do a heap compaction occurs. Again, this is a very expensive operation. The recommendation is to start your application with the minimum heap size that it needs. When it starts up, the Garbage Collector will run often and, because the heap is small, efficiently.

The Garbage Collector takes these steps:

  1. If the Garbage Collector finds enough garbage, it exits.

    If it cannot find enough garbage, it goes to the next step.

  2. The Garbage Collector runs compaction.

    If it cannot find enough garbage, it goes to the next step.

  3. The Garbage collector expands the heap.

Therefore, an application normally runs until the heap is full. Then, successive garbage collection cycles recover garbage. When the heap is full of reachable objects, the Garbage Collector compacts the heap. If and when the heap is full of reachable objects and cannot be compacted, the Garbage Collector expands the heap size.

From the above description, you can see that the Garbage Collector compacts the heap as the needs of the application rise, so that as the heap expands, it expands with a set of compacted objects in the bottom of the original heap. This is an efficient way to manage the heap, because compaction runs on the smallest-possible heap size at the time that compaction is found to be necessary. Compaction is performed with the minimum heap sizes as the heap grows. Some evidence exists that an application's initial set of objects tends to be the key or root set, so that compacting them early frees the remainder of the heap for more short-lived objects.

Eventually, the JVM has the heap at maximum size with all long-lived objects compacted at the bottom of the heap. The compaction occurred when compaction was in its least expensive phase. The overheads of expanding the heap are almost trivial compared to the cost of collecting and compacting a very large fragmented heap.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27378/viewspace-582494/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27378/viewspace-582494/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值