无法更改 tomcat 7 堆大小
我通过在 catalina.sh
中添加以下行来设置 tomcat 7 的堆大小
export CATALINA_OPTS="-Xms512m -Xmx1024m"
,然后停止并启动 tomcat。 但是当尝试使用命令 jmap -heap 获取堆大小时,我注意到内存没有改变:
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 526385152 (502.0MB)
NewSize = 1048576 (1.0MB)
MaxNewSize = 4294901760 (4095.9375MB)
OldSize = 4194304 (4.0MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 16777216 (16.0MB)
MaxPermSize = 67108864 (64.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 99352576 (94.75MB)
used = 9643144 (9.196418762207031MB)
free = 89709432 (85.55358123779297MB)
9.705982862487632% used
From Space:
capacity = 4063232 (3.875MB)
used = 0 (0.0MB)
free = 4063232 (3.875MB)
0.0% used
To Space:
capacity = 5177344 (4.9375MB)
used = 0 (0.0MB)
free = 5177344 (4.9375MB)
0.0% used
PS Old Generation
capacity = 37748736 (36.0MB)
used = 21889008 (20.874984741210938MB)
free = 15859728 (15.125015258789062MB)
57.98606872558594% used
PS Perm Generation
capacity = 60948480 (58.125MB)
used = 31496008 (30.03693389892578MB)
free = 29452472 (28.08806610107422MB)
51.67644541750672% used
请告知。
I have set the heap size of tomcat 7 by adding the following line in catalina.sh
export CATALINA_OPTS="-Xms512m -Xmx1024m"
then stopped and started the tomcat.
but when tried to get the heap size using the command jmap -heap , i can notice that the memory doesn't change:
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 526385152 (502.0MB)
NewSize = 1048576 (1.0MB)
MaxNewSize = 4294901760 (4095.9375MB)
OldSize = 4194304 (4.0MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 16777216 (16.0MB)
MaxPermSize = 67108864 (64.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 99352576 (94.75MB)
used = 9643144 (9.196418762207031MB)
free = 89709432 (85.55358123779297MB)
9.705982862487632% used
From Space:
capacity = 4063232 (3.875MB)
used = 0 (0.0MB)
free = 4063232 (3.875MB)
0.0% used
To Space:
capacity = 5177344 (4.9375MB)
used = 0 (0.0MB)
free = 5177344 (4.9375MB)
0.0% used
PS Old Generation
capacity = 37748736 (36.0MB)
used = 21889008 (20.874984741210938MB)
free = 15859728 (15.125015258789062MB)
57.98606872558594% used
PS Perm Generation
capacity = 60948480 (58.125MB)
used = 31496008 (30.03693389892578MB)
free = 29452472 (28.08806610107422MB)
51.67644541750672% used
please advise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
找到以
JAVA_OPTS="-Djava.awt.headless=true
开头的行,并将 piddly
-Xmx128m
更改为-Xms512m -Xmx1024m
如果您有多个核心...
-XX:+UseConcMarkSweepGC
可能就是您想要的。Find the line that begins
JAVA_OPTS="-Djava.awt.headless=true
and change the piddly
-Xmx128m
to-Xms512m -Xmx1024m
If you have more than one core...
-XX:+UseConcMarkSweepGC
is probably what you want.请勿更改
catalina.sh
!! 用户不应更改此文件。 Tomcat 更新可能会覆盖它。而是在“$CATALINA_BASE/bin”(与catalina.sh
相同的文件夹)中创建一个名为“setenv.sh”的文件。在那里设置所有环境变量。setenv.sh
是一个可选文件。如果存在,则由catalina.sh
导入。这个名字暗示了你放在那里的东西。这是初始化 $CATALINA_OPTS、$JAVA_OPTS 等的合适位置。PS 一般而言,您应该避免调整可能随提供的包/发行版更新而更改的文件,并且存在替代配置方法。在这种情况下,诸如
catalina.sh
、/etc/tomcat7/tomcat7.conf
、/etc/init.d/tomcatX
等文件可以是静默更新,您甚至不会注意到您的配置更改已回滚。Do not change
catalina.sh
!! This file is not supposed to be changed by user. Tomcat updates may override it. Instead create a file called "setenv.sh" in your "$CATALINA_BASE/bin" (same folder ascatalina.sh
). Set all your environment variables there.setenv.sh
is an optional file. If it exists it gets imported bycatalina.sh
. And the name suggests what you put there. This is a proper place to initialize your $CATALINA_OPTS, $JAVA_OPTS, etc.P.S. Generally speaking you should avoid tweaking files that can can change with package/distribution update provided and alternative configuration approach exists. In this case files like
catalina.sh
,/etc/tomcat7/tomcat7.conf
,/etc/init.d/tomcatX
etc can be updated silently and you won't even notice that your configuration changes are rolled back.编辑etc/default/tomcat7怎么样
how about editing etc/default/tomcat7
另外设置
export JAVA_OPTS="-Dcom.sun.management.jmxremote"
并使用 JConsole 检查tomcats内存消耗情况。Set additionally
export JAVA_OPTS="-Dcom.sun.management.jmxremote"
and use JConsole to inspect the tomcats memory consumption.转到您的 catalina.sh
在开头添加这些行
然后使用startup.sh启动您的tomcat
Goto your catalina.sh
Add these line at the beginning
Then start your tomcat using startup.sh