You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Andrievsky Dmitry <di...@teztour.com> on 2005/12/20 10:39:50 UTC

About possible memory leak in Tomcat 5.x

Hello dev,

About a half a year ago I've found that my webapp works fine in
development environment, but leaks memory in production one.
I've searched through all the code, found a few minor errors, but it
didn't help.
(of course, tag pooling are disabled completely)

So then i've tried to use profiler, looking on alien classes.
(I've tried before too, but my attention was concentrated on my own classes)

And then i've found lots of
org.apache.jasper.runtime.PageContextImpl
from which there were a lot of references to the objects, that i've
treated as dead.


All PageContextImpl's lived at
org.apache.jasper.runtime.JspFactoryImpl.pool


There are property of org.apache.jasper.runtime.JspFactoryImpl, named
USE_POOL, which rules pool usage, but it is private,
and i've not found any way to set it to "false" from outside.
Initially it's "true".

So, i've set it to "false" directly in code,
rebuilt tomcat and replaced files ${CATALINA_HOME}/common/lib/jasper-*.jar
from production environment with fresh ones.

So, it seems that the problem is successfully solved.
As far as I can see there no more memory leakage.

I think it would be useful to allow users to set property of
org.apache.jasper.runtime.JspFactoryImpl.USE_POOL from config files or
in any other way, without rebuilding entire tomcat application.

P.S.
In fact, I think, it's not REAL memory leak - memory usage, may be,
will stop grow on some large value (2+ GB, when pool become full), but i have not such
amount of memory.
Now memory usage about 100-200 mb after full gc, depending on amount
of currently working users.

P.P.S What seems to me interesting.
Although before putting PageContextImpl into pool JspFactoryImpl calls
pc.release(), and inside the method all links must become null (or
not?..) and referenced objects must become available to gc, they are not.
May be it is the root of the problem?..

BTW disabling of pool solves the problem completely...


-- 
Best regards,
 Dmitry Andrievsky                            mailto:dimmik@teztour.com


















































































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


Re: About possible memory leak in Tomcat 5.x

Posted by Tino Schwarze <ti...@tisc.de>.
On Tue, Dec 20, 2005 at 12:39:50PM +0300, Andrievsky Dmitry wrote:

> P.P.S What seems to me interesting.  Although before putting
> PageContextImpl into pool JspFactoryImpl calls pc.release(), and
> inside the method all links must become null (or not?..) and
> referenced objects must become available to gc, they are not.  May be
> it is the root of the problem?..

I came across this too and it was caused by Servlets calling
JspFactory.getPageContext(...) and _not_ releasing the PageContext by
calling JspFactory.releasePageContext(...) - which is a real memory
leak (not caused by Tomcat but by the application!). Actually, the
BodyContent array inside PageContextImpl is not reset so the
BodyContents get reused - this might cost significant amounts of memory,
depending on the application.

We have been discussing this recently and it looks like there will be
solution which is useful for everyone: USE_POLL will be made
configurable and maybe big BodyContents will be reset on release().

Bye, Tino.


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