flyapple88
作者flyapple88·2012-07-08 20:43
软件开发工程师·奥盟

IBM JDK 1.4.2 heap

字数 2824阅读 3464评论 0赞 0
Heap size
The maximum heap size is controlled by the -Xmx option. If this option is not
specified, the default applies as follows:
Windows®®
Half the real storage with a minimum of 16 MB and a maximum of
2 GB -1.
OS/390®® and AIX®
64 MB.
Linux Half the real storage with a minimum of 16 MB and a maximum of
512 MB -1.
The initial size of the heap is controlled by the -Xms option. If this option is not
specified, the default applies as follows:
Windows, AIX, and Linux
4 MB
OS/390
1 MB
Some basic heap sizing problems
For the majority of applications, the default settings work well. The heap expands
until it reaches a steady state, then remains in that state, which should give a heap
occupancy (the amount of live data on the heap at any given time) of 70%. At this
level, the frequency and pause time of garbage collection should be acceptable.
For some applications, the default settings might not give the best results. Listed
here, are some problems that might occur, and some suggested actions that you
can take. Use verbosegc to help you monitor the heap.
The frequency of garbage collections is too high until the heap reaches a steady
state.
Use verbosegc to determine the size of the heap at a steady state and set -Xms
to this value.
The heap is fully expanded and the occupancy level is greater than 70%.
Increase the -Xmx value so that the heap is not more than 70% occupied, but
for best performance try to ensure that the heap never pages. The maximum
heap size should, if possible, be able to be contained in physical memory.
At 70% occupancy the frequency of garbage collections is too great.
Change the setting of -Xminf. The default is 0.3, which tries to maintain 30%
free space by expanding the heap. A setting of 0.4, for example, increases this
free space target to 40%, and reduces the frequency of garbage collections.
Pause times are too long.
Try using -Xgcpolicy:optavgpause. This reduces the pause times and makes
them more consistent when the heap occupancy rises. It does, however, reduce
throughput by approximately 5%, although this value varies with different
applications.
overview of garbage collection
Chapter 2. Understanding the Garbage Collector 9
Here are some useful tips:
v Ensure that the heap never pages; that is, the maximum heap size must be able
to be contained in physical memory.
v Avoid finalizers. You cannot guarantee when a finalizer will run, and often they
cause problems. If you do use finalizers, try to avoid allocating objects in the
finalizer method. A verbosegc trace shows whether finalizers are being called.
v Avoid compaction. A verbosegc trace shows whether compaction is occurring.
Compaction is usually caused by requests for large memory allocations. Analyze
requests for large memory allocations and avoid them if possible. If they are
large arrays, for example, try to split them into smaller arrays.

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广