tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <d...@cornell.edu>
Subject Re: Tomact 5 - Out of Memory
Date Wed, 04 Aug 2004 18:12:51 GMT
The JVM and Tomcat don't (that I know about), but there are ways for a 
servlet to continue to eat up memory with out freeing it.  Here's just one:

Servlet A instantiates some collection like a Hashtable in it's constructor.
Servlet A then procedes to add stuff to that Hashtable without removing 
anything at the end of the request.
Next request comes in and because the servlet is pooled between 
requests, the Hashtable is the same one from the first request and still 
has all the old stuff from before in it.
Servlet A adds even more stuff while servicing this request, but still 
hasn't removed any of the old stuff by the end of processing.
Keep recycling this servlet until the JVM is full and there is no room 
for anything else.  Better yet, multiply this servlet by however threads 
tomcat had to create to keep up with the request load.

Lesson to learn: free any objects explicitly you don't intend to keep 
around from request to request.

--David

Jon Doe wrote:

>> From: David Smith <dns4@cornell.edu>
>> Reply-To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
>> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
>> Subject: Re: Tomact 5 - Out of Memory
>> Date: Wed, 04 Aug 2004 07:38:57 -0400
>>
>> I would set JAVA_OPTS in the startup script you're using to start
>> Tomcat. There are loads of emails on the list regarding this. This issue
>> is common enough you should be able to google the archives for details
>> and get loads of responses.
>
>
> Fair point -- if you haven't enough memory overhead, then until the 
> garbage collector kicks in to free objects up you will have a problem.
>
>>
>> Also as others have suggested, check your code for memory leaks --
>> especially if it's not under load when it dies.
>
>
> But hey, I thought one of the big selling points is that Java DOES NOT 
> LEAK! Am I mistaken? Isn't it's absence of pointers its big plus? If 
> it does leak then changing the heap size is going to be irrelevant. No 
> matter how large you set it it will bite you in the bum eventually!
>
>>
>> --David
>>
>
> _________________________________________________________________
> Tired of spam? Get advanced junk mail protection with MSN 8. 
> http://join.msn.com/?page=features/junkmail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message