java-jvm usage analytics

本文详细分析了两个运行Solr应用的Tomcat实例在内存分配、JVM配置、实际内存使用等方面的差异。通过对比各参数值,包括Xms、Xmx、Xmn、NewRatio、SurvivorRatio等,以及使用'jmap-heappid'和'top-RES'命令获取的内存使用情况,揭示了实例A和实例B在内存管理和资源利用上的不同。此外,文章还探讨了Xms和Xmx的区别,以及实例B的实际新大小为何远大于实例A,但实际使用的内存却较少的原因。通过分析,得出了实例B的CMS收集器可能比实例A更早启动的结论,并量化了这种差异带来的内存使用效率提升。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  as mentioned in title,i will make  analytics between two tomcats which both running a solr app.

 

1.cases comparison

2.analytics

 

1.cases comparison

tomcatXmsXmxXmnNewRatio

SurvivorRatio

mem used by

checking 'top-RES' item

resulted: actual new size

A6g8g1.5g-64.1g1.5g
B20g20g-464.9g4g
        

 these are the jvm allocation by checking 'jmap -heap pid'

 tomcat A

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 8589934592 (8192.0MB)
   NewSize          = 1572864000 (1500.0MB)
   MaxNewSize       = 1572864000 (1500.0MB)
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 4
   SurvivorRatio    = 6
   PermSize         = 67108864 (64.0MB)
   MaxPermSize      = 104857600 (100.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 1376256000 (1312.5MB)
   used     = 782190664 (745.9551467895508MB)
   free     = 594065336 (566.5448532104492MB)
   56.83467785063244% used
Eden Space:
   capacity = 1179648000 (1125.0MB)
   used     = 738672576 (704.4530639648438MB)
   free     = 440975424 (420.54693603515625MB)
   62.61805013020833% used
From Space:
   capacity = 196608000 (187.5MB)
   used     = 43518088 (41.50208282470703MB)
   free     = 153089912 (145.99791717529297MB)
   22.134444173177084% used
To Space:
   capacity = 196608000 (187.5MB)
   used     = 0 (0.0MB)
   free     = 196608000 (187.5MB)
   0.0% used
concurrent mark-sweep generation:
   capacity = 4869586944 (4644.0MB)
   used     = 2786356080 (2657.2762298583984MB)
   free     = 2083230864 (1986.7237701416016MB)
   57.2195570598277% used
Perm Generation:
   capacity = 67108864 (64.0MB)
   used     = 37844912 (36.09172058105469MB)
   free     = 29263952 (27.908279418945312MB)
   56.39331340789795% used

 

 tomcat B

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 21474836480 (20480.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 4
   SurvivorRatio    = 6
   PermSize         = 67108864 (64.0MB)
   MaxPermSize      = 104857600 (100.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 3758096384 (3584.0MB)
   used     = 1372982952 (1309.3785781860352MB)
   free     = 2385113432 (2274.621421813965MB)
   36.53400050742285% used
Eden Space:
   capacity = 3221225472 (3072.0MB)
   used     = 1277111448 (1217.948387145996MB)
   free     = 1944114024 (1854.051612854004MB)
   39.646757394075394% used
From Space:
   capacity = 536870912 (512.0MB)
   used     = 95871504 (91.43019104003906MB)
   free     = 440999408 (420.56980895996094MB)
   17.85745918750763% used
To Space:
   capacity = 536870912 (512.0MB)
   used     = 0 (0.0MB)
   free     = 536870912 (512.0MB)
   0.0% used
concurrent mark-sweep generation:
   capacity = 17179869184 (16384.0MB)
   used     = 1514222648 (1444.0752487182617MB)
   free     = 15665646536 (14939.924751281738MB)
   8.813935844227672% used
Perm Generation:
   capacity = 67108864 (64.0MB)
   used     = 37938264 (36.180747985839844MB)
   free     = 29170600 (27.819252014160156MB)
   56.532418727874756% used

 

2.analytics

  A.from all of info above,we know that :

   RES~new gen-size + one survivor-size+ old gen's used-size + perm used= new eden + 2* survivor + old gen's used + perm used

   so the above tomcat A's RES = 4.1g ~ 1312.5MB + 187.5MB + 2657mb + 36mb= 4193mb 

   that means the total mem used is always couted by base part say 'new size' ,added by actual used old size and used perm size.in fact it's reasonable.

  B.the Xmx is the large size of the heap ,so jvm does not always reach it,but what about Xms?is it the min pre-allocated size guaranteed by jvm ?

  nope,we know,the RES is far less than it.

  C.jvm misc gen allcotion for mem.the tomcat B 's 'actual new size' is 4g >> 1.5g which tomcat A used,but u will find that the actual used mem size is less than the A.

  A current used mem:704+41+2657 ~2.4g

  B 's one:1217+91 +1444 ~ 2.7g

   that means 2.7-2.4=300mb objects have been destroyed in 'new area';

   and the old size used:A/2657 ~ 2 * B/1444, that means the Tomcat A jvm will first come into CMS compared to B;and of course,the A 's new-collection-time is much less than B,about half of time saved,say ~25ms .

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值