tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian" <>
Subject RE: Tomcat 6.0.29 using more and more RAM until it collapses?
Date Fri, 12 Nov 2010 20:02:15 GMT
Hi Chris,

I saved your email and hadn't replied yet. Here are my responses, thanks!

> -----Original Message-----
> From: Christopher Schultz []
> Sent: Thursday, November 11, 2010 02:39 PM
> To: Tomcat Users List
> Subject: Re: Tomcat 6.0.29 using more and more RAM until it collapses?
> Brian,
> On 11/11/2010 1:54 PM, Brian wrote:
> > I don't think my app is taking all this RAM, because when I restart
> > it, the RAM usage doesn't go down.
> That doesn't necessarily mean that your webapp isn't using all that heap
> space: it's very easy for a webapp to do something foolish and cause all of it's
> used memory to stay active even after a webapp restart.

Yes, now I know that.
> I disagree with Ben's comment about database connections: there are faster
> ways to bust your heap than leaking database connections. If you /are/ using
> Tomcat's container-managed DataSource (which I highly recommend), you
> should enable all of the abandoned resource tracking features to help fix any
> resource leaks that you may have there.

Well, the database relation with my code is not the problem, I'm using a pool and it works
I don’t know for what else should I use the DataSource. 

> I agree with Chuck's assessment, but there may be some questions we can ask to
> help lead you down the right path when using tools such as memory profilers.
> 0. What kind of OOME are you suffering? Please post any messages that
>    you get when your heap busts. Specifically, is this a "regular" heap
>    exhaustion or a PermGen exhaustion?

Good question, but I can't answer that. I think I lost my logs.   :-(
I will search for them again.
But I could use the profiler now and responde whatever you would like to ask about how is
it behaving now.

> 1. Are you seeing any messages in catalina.out when you undeploy of
>    the form "your webapp likely has a memory leak"? Tomcat 6.0.x has
>    some nice checks on undeploy to see if your webapp is leaking
>    some specific things like threads, etc.

Yeah, I have seen those lately.

> 2. Are you re-starting your webapp a lot while Tomcat remains running?
>    Failure to perform some clean-up during webapp unload can cause
>    your entire set of classes loaded in the "old" webapp to stay in
>    the PermGen space forever.

No, I don’t restart them frequently. But I do redeploy them frequently, in the past I did
it deleting the WAR in the directly and uploading a new one, now I'm suing the Tmocat Manager
do undeploy and deploy again.

> 3. Are you using any caching mechanism in your webapp? Perhaps it needs
>    to be tuned. You should probably check out what's in your
>    "application" scope: you may have things you didn't expect.

I do have some caches in my objects. For example, the ir an object called "BrandsManager"
which has methods like "getBrands(), getBrand(int id), insertBrand" and so on. The getBrands()
method goes to the database only the first time, and then creates a LinkedList with the data.
But I don't think this kind of caching is the problem, they consume a minimal amount of memory.

> 4. Are you using HttpSession for anything bulky? It's possible that
>    you are "leaking" memory with lots of sessions. When a webapp
>    is stopped, though, all session should be purged and if you
>    have session persistence, they should all come back and take
>    up the same amount of memory. This is a long-shot, but low-hanging
>    fruit.

No, I don’t store anything big in the sessions. I just store some strings in them. Nothing
How do I know if I have session persistence?

> You can get a lot of mileage out of a tool like "jmap" which comes with the JDK
> (and JRE?): you can get a heap histogram and look at things that are taking up a
> lot of space. If you find that you have several tens of megabytes of
> classes, then you can look at your app to see where you heavy uses of those
> classes are.

I'm already using yourkit, which I guess is even better.

> To understand #2 a bit better, see Mark's presentation from this year's
> ApacheCon NA:
> 60mins.pdf

I will now!!

> It's worth a read to understand how simple things like using a logging library can
> cause PermGen exhaustion after several webapp redeploy operations.

Well, I'm using the Tomcat log indeed. And I also saw a lot of memory being used by that!
But more memory is being used by the cached static pages, so I guess I should start with that.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message