resin版本3.1 java版本1.5 操作系统版本 centos 4.6
服务器的cpu消耗很低,但内存消耗很快,不到一个小时就吃到交换分区了,把swap分区吃完了,机器就挂掉了。我们配置的时候是Apache和resin结合使用的,apache通过6800端口把jsp传给resin处理。
resin.conf 配置文件里面配置有5个HOST,另外jvm的配置参数是这样的:
[code="java"]
-Xmx2048m
-Xms2048m
-XX:MaxPermSize=128m
-Xmn1200m
-XX:ParallelGCThreads=20
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-Xss1m
-Xdebug
[/code]
top结果:
top - 16:47:38 up 1 day, 2:23, 1 user, load average: 5.30, 3.81, 1.82
Tasks: 128 total, 2 running, 126 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.2% us, 13.3% sy, 0.0% ni, 71.3% id, 14.1% wa, 0.0% hi, 0.1% si
Mem: 8161396k total, 8137632k used, 23764k free, 388k buffers
Swap: 8385920k total, 2892784k used, 5493136k free, 8320k cached
[b]问题补充:[/b]
java进程号8536
[code="java"]
top - 21:16:07 up 1 day, 6:51, 2 users, load average: 0.16, 0.17, 0.20
Tasks: 128 total, 1 running, 127 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.4% us, 0.1% sy, 0.0% ni, 98.5% id, 0.1% wa, 0.0% hi, 0.0% si
Mem: 8161396k total, 7809248k used, 352148k free, 14676k buffers
Swap: 8385920k total, 516368k used, 7869552k free, 582428k cached
PID USER PR NI %CPU TIME+ %MEM VIRT SWAP RES CODE DATA SHR S COMMAND
8536 root 16 0 11 4:35.74 84.5 8920m 2.1g 6.6g 52 8.5g 36m S java
[/code]
java进程占用内存87.4%,进程号8536
[code="java"]
ps aux
root 8536 9.2 87.4 9417572 7136552 ? Sl 20:26 4:43 /usr/local/jdk1.5.0_17/bin/java -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djava.system.class.loader=com.caucho.loader
[/code]
第二次top:
[code="java"]
top - 21:20:28 up 1 day, 6:55, 2 users, load average: 0.08, 0.11, 0.16
Tasks: 131 total, 1 running, 130 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.2% us, 0.6% sy, 0.0% ni, 97.1% id, 1.1% wa, 0.0% hi, 0.0% si
Mem: 8161396k total, 8124104k used, 37292k free, 564k buffers
Swap: 8385920k total, 540296k used, 7845624k free, 40192k cached
PID USER PR NI %CPU TIME+ %MEM VIRT RES SHR S COMMAND
8536 root 16 0 10 5:08.40 95.8 9.8g 7.5g 28m S java
121 root 16 0 4 35:51.87 0.0 0 0 0 D kswapd0
[/code]
第三次top:
[code="java"]
top - 21:23:00 up 1 day, 6:58, 2 users, load average: 0.14, 0.16, 0.17
Tasks: 131 total, 1 running, 130 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.6% us, 0.2% sy, 0.0% ni, 97.9% id, 0.2% wa, 0.0% hi, 0.0% si
Mem: 8161396k total, 8125048k used, 36348k free, 1060k buffers
Swap: 8385920k total, 1082024k used, 7303896k free, 38212k cached
PID USER PR NI %CPU TIME+ %MEM VIRT SWAP RES CODE DATA SHR S COMMAND
8536 root 16 0 14 5:27.79 97.1 10.5g 2.9g 7.6g 52 10g 28m S java
121 root 15 0 2 35:54.77 0.0 0 0 0 0 0 0 S kswapd0
[/code]
第四次top:
[code="java"]
Tasks: 131 total, 1 running, 130 sleeping, 0 stopped, 0 zombie
Cpu0 : 2.8% us, 0.4% sy, 0.0% ni, 95.7% id, 0.9% wa, 0.0% hi, 0.1% si
Cpu1 : 0.6% us, 0.3% sy, 0.0% ni, 98.7% id, 0.4% wa, 0.0% hi, 0.0% si
Cpu2 : 0.7% us, 1.2% sy, 0.0% ni, 96.4% id, 1.7% wa, 0.0% hi, 0.0% si
Cpu3 : 0.6% us, 0.5% sy, 0.0% ni, 98.3% id, 0.7% wa, 0.0% hi, 0.0% si
Cpu4 : 0.5% us, 0.3% sy, 0.0% ni, 98.7% id, 0.4% wa, 0.0% hi, 0.0% si
Cpu5 : 0.6% us, 0.3% sy, 0.0% ni, 98.7% id, 0.4% wa, 0.0% hi, 0.0% si
Cpu6 : 0.7% us, 0.7% sy, 0.0% ni, 97.7% id, 1.0% wa, 0.0% hi, 0.0% si
Cpu7 : 0.5% us, 0.3% sy, 0.0% ni, 98.8% id, 0.4% wa, 0.0% hi, 0.0% si
Mem: 8161396k total, 8113456k used, 47940k free, 292k buffers
Swap: 8385920k total, 1564668k used, 6821252k free, 32044k cached
PID USER PR NI %CPU TIME+ %MEM VIRT RES SHR S COMMAND
8536 root 16 0 9 5:55.63 97.8 11.1g 7.6g 26m S java
121 root 15 0 4 36:12.40 0.0 0 0 0 S kswapd0
[/code]
[code="java"]
ps aux
root 8536 10.0 97.5 11760484 7962748 ? Sl 20:26 5:58 /usr/local/jdk1.5.0_17/bin/java -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djava.system.class.loader=com.caucho.loader
[/code]
第五次top(swap已经到2G了):
[code="java"]
top - 21:29:20 up 1 day, 7:04, 2 users, load average: 5.53, 2.84, 1.23
Tasks: 131 total, 2 running, 129 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.0% us, 9.8% sy, 0.0% ni, 68.4% id, 20.8% wa, 0.0% hi, 0.0% si
Mem: 8161396k total, 8122488k used, 38908k free, 280k buffers
Swap: 8385920k total, 2263088k used, 6122832k free, 29776k cached
PID USER PR NI %CPU TIME+ %MEM VIRT RES SHR S COMMAND
121 root 16 0 95 37:43.77 0.0 0 0 0 R kswapd0
32161 root 16 0 19 17:29.02 0.1 1079m 5600 3528 S java
8536 root 16 0 19 6:43.04 98.3 11.9g 7.7g 25m S java
[/code]
[code="java"]
ps aux
root 8536 10.7 98.3 12598116 8025284 ? Sl 20:26 6:48 /usr/local/jdk1.5.0_17/bin/java -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djava.system.class.loader=com.caucho.loader
[/code]
检测内存分配:
[code="java"]
vmstat 5
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
1 0 593940 38444 824 40576 26 40 32 43 2 16 1 1 98 1
0 0 622980 43740 824 40672 248 5808 248 5864 1198 1493 2 0 97 1
0 0 649200 41756 852 40756 2166 5308 2190 5347 1274 17118 1 0 94 5
0 0 669316 38108 868 40948 13 4030 13 4064 1187 869 1 0 98 1
0 0 673568 47268 888 40564 13 2203 14 2238 1220 867 1 0 98 1
0 0 679384 40572 908 40192 208 2867 211 2918 1243 924 2 0 97 2
1 0 685080 43964 840 38196 32 4185 32 4220 1286 5405 2 0 97 2
0 0 685280 43068 872 38108 150 3086 174 3128 1502 940 1 0 93 6
0 0 683952 46964 776 36468 814 4018 821 4069 1452 989 1 0 92 6
0 3 685628 46612 808 36516 131 5669 134 5706 1360 940 2 0 92 6
0 1 688560 46428 312 34936 462 2614 471 2658 1372 965 2 4 89 5
0 1 690816 42140 340 33948 399 1882 491 1938 1351 1239 2 1 94 4
0 0 713104 44052 308 33548 906 6016 906 6062 1484 954 1 0 90 8
0 1 745548 36852 496 33684 2371 6489 2406 6524 1312 1132 1 0 93 5
0 0 766192 44924 620 33852 1130 4131 1183 4166 1251 1009 2 0 95 3
0 0 802552 42428 652 34012 638 7272 648 7324 1243 5389 2 0 96 2
vmstat 5
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 11 2401820 31692 380 31052 27 42 33 45 3 19 1 1 98 1
1 3 2407864 37516 332 29172 3432 2327 3702 2370 1524 1221 1 14 66 20
1 0 2409332 25364 320 29164 4075 1054 4582 1090 1529 1314 1 11 72 16
1 1 2430024 25236 308 29764 3578 4680 4086 4714 1439 1249 1 12 75 12
4 2 2437212 23764 316 30032 4291 2304 4861 2362 1513 1284 1 16 71 12
7 2 2454028 23764 336 29740 5968 4057 6538 4102 1639 1492 1 40 45 14
0 0 2500428 36868 348 30840 4363 9719 4910 9735 1390 71980 0 39 46 14
[/code]
[b]问题补充:[/b]
@pJun;
两台机器做集群:
1.dell 2950 高配:64位,8G,CPU 8个
2.dell 2950 标配:32位,4G,CPU 8个
两台机器其它配置都一样,跑的程序也相同,但64位的内存泄露相当严重,大概一个小时就会物理内存全部耗光,swap2G全部耗光,需要重启。
32位 没这种情况,偶尔也会有一次,32位物理内存耗到只剩4 50M的时候,就不会用swap了,而是自动重启java服务进程,然后内存就会恢复到启动时候的状态。
64位机器 resin配置文件里最大线程是400,
64位的机器通过jconsole 观察垃圾回收时正常的:在resin配置文件里分配2G内存给jvm,当内存到1.5G的时候,会自动回收)
跟系统环境变量有没有关系,我感觉跟分配的线程有问题?