tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Tomcat - OOM Perm gen
Date Mon, 06 Jul 2015 20:38:19 GMT
Hash: SHA256


On 7/5/15 10:24 AM, Kiran Badi wrote:
> Sorry for taking time to reply Chris.
>> Christopher Schultz wrote: Are you periodically hot-re-deploying
>> your application in production? If so, you may want to stop doing
>> that, as it appears that you have a ClassLoader-pinning leak in
>> your application or some dependent library
> I do not do hot deployment in production. But somehow I feel its
> leaking memory.

What makes you think that?

> There are some threads which for some reasons remains hanging.

Threads related to Tomcat, or threads that are started by your

> But I think I will focus on it later on. I do have copy of your 
> presentation. I will go through it and may be post couple of
> question if I have.

The presentation is markt's, not mine.

>> You should be able to run a reasonable service in half a gig of
>> heap space. Just be aware that caching information in your
>> application is going to significantly increase the amount of heap
>> space required by your application in a steady-state.
> Yup I am aware of this limitation. I know cache is often stored in
> local heap and probably that's reason it consumes heap space.

Well... there are many ways to cache data, but if you are caching it
in your application (and not in an out-of-process-cache like ehcache,
memcached, etc.) then by definition it's in your application's heap spac

> Currently I am checking if ehcache or jcs meets my need. Ehcache
> for some reasons fills my heap very fast.I tried storing some 100
> json strings and retrieving them. My OOM's started once I
> integrated this library in my web inf /lib folder.After I removed
> it, frequency of OOM has substantially decreased.Probably I am not
> using it correctly somewhere.

You may also be using in-memory caching as opposed to on-disk caching.

> Do you know what open source caching people frequently use for java
> web apps ?

Honestly, I would spend your time by disabling any caching and making
sure that the application doesn't leak memory *before* you add any
caching before you start introducing any kind of caching.

>> Fetching a lot of data isn't usually a big deal. Just make sure
>> that your "fetch size" is set to something reasonable. There are
>> some JDBC drivers (MySQL Connector/J in particular) that will
>> load the entire ResultSet into memory before allowing you to
>> traverse it unless you make arrangements to limit that memory
>> usage.
>> But bringing-back thousands of records from a db isn't a problem
>> -- unless you don't *have to* in which case you might want to
>> optimize your queries to avoid pulling data you don't actually
>> need.
>> But too-many-records would be a performance problem, not a
>> memory problem.
> haha.Its fetch size which my autocomplete was missing...I am not
> sure how I missed it but it was missing.

I would remove all the caching and make sure that the application
works properly without leaking any memory before moving on to improve

To do otherwise would be considered premature optimization. Nobody
likes an application that falls-over, even if it does so with
high-performance. Users will tolerate a slow application if it's the
only thing wrong with it.

- -chris
Comment: GPGTools -


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

View raw message