Topic: 内存使用情况,怪现象!

  Print this page

1.内存使用情况,怪现象! Copy to clipboard
Posted by: windshome
Posted on: 2008-09-08 10:34

我写了一个TCPServer,在100并发的客户端压力下,使用jconsole来看内存,很怪异,哪位帮忙看看是什么地方有问题?
先谢过。

(缩略图,点击图片链接看原图)

2.Re:内存使用情况,怪现象! [Re: windshome] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2008-09-10 03:53

这个很可能是因为TCP Server软件设计的问题.
你觉得哪里怪异了?
100并发客户端会逐渐在服务器端占用内存,很正常阿.

3.Re:内存使用情况,怪现象! [Re: windshome] Copy to clipboard
Posted by: windshome
Posted on: 2008-09-10 09:38

我奇怪的是内存是的使用和平时不大一样。在图中,应该是fullGC比较多。我感觉理想的情况应该是:

YongGC比较多,也比较频繁,但是每次YongGC的带来的暂停时间也短
FullGC比较少

现在的状况是YongGC回收的非常少(很多对象都保存在了老生代),老生代满了之后FullGC,所以非常奇怪。

gc1.log (870.06k)

4.Re:内存使用情况,怪现象! [Re: windshome] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2008-09-10 19:31

I think it is called "Young generation and the Tenured generation", see the link below:
http://java.sun.com/docs/hotspot/gc1.4.2/faq.html

I am not familiar with the Garbage Collection, but some points from the document above seems suspicious and might be related to your issue here.

1. How is the generational collector implemented in HotSpot(tm)?

The default collector in HotSpot has two generations: the young generation and the tenured generation. Most allocations are done in the young generation. The young generation is optimized for objects that have a short lifetime relative to the interval between collections. Objects that survive several collections in the young generation are moved to the tenured generation. The young generation is typically smaller and is collected more often. The tenured generation is typically larger and collected less often.

11. What is the best size for the young generation?

The young generation should be sized large enough so that short-lived objects have a chance to die before the next young generation collection. This is a tradeoff since a larger young generation will allow more time for objects to die but may also take longer to collect. Experiment with the size of the young generation to optimize the young generation collection time or the application throughput.

12. What should I do if my application has mid- or long-lived objects?

Objects that survive a young generation collection have a copying cost (part of the algorithm for a young generation collection is to copy any objects that survive). Mid- or long-lived objects may be copied multiple times. Use the -XX option MaxTenuringThreshold to determine the copying costs. Use -XX:MaxTenuringThreshold=0 to move an object that survives a young generation collection immediately to the tenured generation. If that improves the performance of the application, the copying of long-lived objects is significant. Note that the throughput collector does not use the MaxTenuringThreshold parameter.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923