开发者

Tomcat: Passing -XX:MaxPermSize has no visible effect

开发者 https://www.devze.com 2023-04-11 04:56 出处:网络
I am trying to deploy my application to Tomcat, but haven\'t been able to do so. I constantly keep getting OutofMemoryError permgen space.

I am trying to deploy my application to Tomcat, but haven't been able to do so. I constantly keep getting OutofMemoryError permgen space. I have tried various command line switches(searched different questions regarding this on stackoverflow) like -XX:MaxPermSize, -XX:PermSize, -XX:+CMSClassUnloadingEnabled, -XX:+CMSPermGenSweepingEnabled

I gave the permgen size as 64, 128, 256, 512, but none of them works.

Interestingly, when I receive the error, I see in task manager the java process is only taking up about 300mb memory. I am passing -Xms as 1024m, but still the memory consumption is around 300m开发者_StackOverflow中文版b.

Looking for opinions on what could be the reason?

My system details: Dell Latitude 5420 Win XP 32 Bit 4 GB RAM


When you say "constantly", do you mean after you've done several redeploys in a row? If yes, this is a well-known flaw with Tomcat that you can't do anything about. Increasing perm gen space will only delay the inevitable.

The reason is that reflection creates classes dynamically that end up in the perm gen space, never to be reclaimed. Hence the name 'perm gen' - this is the permanent generation that the garbage collector doesn't touch.

Conservation laws tell you that if you have a finite capacity, and you only add to it without removing, you'll eventually run out of capacity. That's what is happening to you here.


In addition to Udo Fholl's answer: The right parameter for Maximum Heap ist -Xmx1024M


Tomcat needs the environment-variable JAVA_OPTS. For example:

JAVA_OPTS="-XX:MaxPermSize=256m -Xms250m -Xmx650m"


-Xms=1024 means that the starting memory is 1024, but then, when it is not needed it shrink it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号