tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Adams <bad...@ambrosiasw.com>
Subject Re: cpu 100% java
Date Wed, 02 Aug 2006 19:44:01 GMT

On Aug 1, 2006, at 5:55 PM, Christopher Schultz wrote:

> Ben,
>
>> I'm on OS X 10.4.7 running with weblog software (blojsom)
>> I have to do a kill -9 on java to stop it from using 100+ on cpu
>> sometimes, to let users connect.
>
> I assume that you also have to restart Tomcat at this point, yes?
I just kill Java, Tomcat auto restarts it.

>
>> This comes up over and over in the log:
>> 2006-08-01 17:22:08 StandardWrapperValve[blojsom]: Servlet.service 
>> () for
>> servlet blojsom threw exception
>> javax.servlet.ServletException: Servlet execution threw an exception
>
> [snip]
>
>> ----- Root Cause -----
>> java.lang.OutOfMemoryError: Java heap space
>
> You done run outta memory. Since this question ("why did I run out of
> memory") comes up a lot, I'll save you some time going through the
> gauntlet of one-off responses you are likely to get:
>
> 3. There might be a memory leak. Since you are getting 100% CPU use,
>    you might have found a problem with the software getting it into
>    a tight and infinite loop (or, at least sufficiently many  
> iterations
>    that it may as well be infinite) that generates loads of objects:
>    hence, your memory exhaustion. Make sure you have the latest  
> patches
>    from the vendor.
>
>
How much ram do I set?
Load Avg:  1.30, 1.28, 1.22     CPU usage:  51.3% user, 8.4% sys,  
40.3% idle
SharedLibs: num =  137, resident = 22.8M code, 3.20M data, 6.41M  
LinkEdit
MemRegions: num =  7345, resident =  142M + 8.15M private, 27.4M shared
PhysMem:  61.1M wired, 68.0M active,  173M inactive,  302M used,   
209M free
VM: 3.44G + 89.5M   18117(0) pageins, 0(0) pageouts

   PID COMMAND      %CPU   TIME   #TH #PRTS #MREGS RPRVT  RSHRD   
RSIZE  VSIZE
   825 java       102.4%  2:43:34  61   >>>   371  98.0M   872K   
85.1M-  308M

Should have 209MB Available.

>
> After that, it's just a matter of changing your memory settings.  
> How you
> do that depends on your deployment, but generally you set the
> environment variable JAVA_OPTS and use the "-X" parameters to set the
> Java heap size.

I added this to catalina.sh:
JAVA_OPTS="$CF_JVM_OPTIONS -Xms128m -Xmx256m"

>
> Often, it helps to set the initial and maximum heap sizes to the same
> thing, so that the memory manager never has to grow the heap during  
> the
> life of the process -- that can save time and avoid OOMs if Java  
> demands
> too much memory too fast (I really hope this is fixed in recent  
> versions
> of the JVM... this used to happen and it really should not).
>
> Hope that helps,
>
> -chris
>
>
Thanks
--Ben


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message