2 njustwalker njustwalker 于 2016.09.08 19:44 提问

CentOS Tomcat 内存占用问题

CentOS 6.5
Tomcat 7.0.55
和在win7下面跑同样个程序内存占用相差巨大
win7下任务管理器看内存占用500-600M之间浮动
CentOS 刚启动500M 随着时间推移越来越大 最高达到过1.7G
用jconsole看过CentOS下堆内存和非堆内存
稳定在150M和60M左右 用jmap看到的也是相同数据
并且检查过DirectMemory 直接通过OS分配的内存 也没有超过默认64m限制
栈内存已经调整到256k最小值
线程是有波动的 但是总内存是越来越大和线程数波动不成正比
用jmap dump出内存 然后用eclipse mat分析过 大概有80M+的内存泄露
求大神指点可能的问题 我已经黔驴技穷了

6个回答

wangzhongzhou1990
wangzhongzhou1990   2016.09.09 10:25

JAVA_OPTS="$JAVA_OPTS -server -XX:PermSize=128m -XX:MaxPermSize=256m"

njustwalker
njustwalker   2016.09.13 09:14

谢谢上面朋友回复

永久区使用率也不到50%

njustwalker
njustwalker   2016.09.13 09:38

具体情况如下:

Server compiler detected.
JVM version is 24.80-b11

using thread-local object allocation.
Parallel GC with 2 thread(s)

Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 1073741824 (1024.0MB)
NewSize = 1310720 (1.25MB)
MaxNewSize = 268435456 (256.0MB)
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 268435456 (256.0MB)
MaxPermSize = 268435456 (256.0MB)
G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
capacity = 266338304 (254.0MB)
used = 1242592 (1.185028076171875MB)
free = 265095712 (252.81497192382812MB)
0.46654648668184057% used
From Space:
capacity = 1048576 (1.0MB)
used = 0 (0.0MB)
free = 1048576 (1.0MB)
0.0% used
To Space:
capacity = 1048576 (1.0MB)
used = 0 (0.0MB)
free = 1048576 (1.0MB)
0.0% used
PS Old Generation
capacity = 805306368 (768.0MB)
used = 92039160 (87.77538299560547MB)
free = 713267208 (680.2246170043945MB)
11.429086327552795% used
PS Perm Generation
capacity = 268435456 (256.0MB)
used = 134408312 (128.18175506591797MB)
free = 134027144 (127.81824493408203MB)
50.07099807262421% used

28110 interned Strings occupying 3206696 bytes.

njustwalker
njustwalker   2016.09.13 09:42

top 命令情况如下:
top - 09:38:29 up 66 days, 14:53, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 88 total, 1 running, 87 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.3%us, 0.2%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 3924684k total, 3485476k used, 439208k free, 176944k buffers
Swap: 0k total, 0k used, 0k free, 319416k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

2259 www 20 0 2881m 1.8g 12m S 0.0 47.5 29:02.30 java

njustwalker
njustwalker   2016.09.13 09:43

求大侠帮忙分析问题 万分感谢

njustwalker
njustwalker   2016.09.13 10:06

bash-4.1$ jstat -gcutil 2259 1000 20
S0 S1 E O P YGC YGCT FGC FGCT GCT

0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703
0.00 0.00 0.47 11.52 50.09 3592 20.818 3486 899.885 920.703

附上jstat命令状态
Csdn user default icon
上传中...
上传图片
插入图片