tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Re : Memory leak in Tomcat 6.0.35 ( 64 bit)
Date Mon, 15 Apr 2013 17:08:49 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Howard,

On 4/14/13 9:53 PM, Howard W. Smith, Jr. wrote:
> I am definitely relying on  user HttpSessions, and I do JPA-level
> caching (statement cache and query results cache). pages are
> PrimeFaces and primefaces = xhtml, html, jquery, and
> MyFaces/OpenWebBeans to help with speed/performance.  And right
> now, the app handles on a 'few' simultaneous connections/users that
> do small and large fetches/inserts from/into relational database.
> :)

You can tune the JPA caching, etc. to meet your environmental needs,
etc., so you don't *need* a huge heap. If you find that you need to be
able to improve your performance, you might be able to increase your
cache size if it in fact improves things.

> sometimes, i do keep large amount of data in user HttpSession
> objects, but still being somewhat junior java/jsf developer and
> listening to you all on tomcat list and other senior java/jsf
> developers, I want to move some of my logic and caching of data
> from SessionScoped beans to RequestScoped beans.

You might be able to have your cake and eat it, too. There is an
interesting class called WeakReference that you can use to interact
with the memory manager and garbage-collector. If you have a bunch of
stuff cached in the session, as long as you could re-construct the
cache given some value (like user_id or whatever), you can make the
big, cached stuff in the session into so-called weak-references. If
the GC wants to re-claim memory, it can discard weak references and
the WeakReference object will then point to null. That allows you to
have a nice cache that auto-cleans if you start running low on memory.

I've written a Filter and HttpSession wrapper that can do that kind of
thing transparently to the application code. I don't actually use it
right now -- it was just a proof-of concept -- but it's a quick and
dirty way to get caching but also save a safety valve.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRbDQhAAoJEBzwKT+lPKRY2voP/RejVzXwT9q3Bpq8C85sdmaU
rf4l8aSAeHY9iZDuU27dGIPYcM8eD503UFdLxNrLQmsAnIGgecxcybSzTCIaA8Q1
kqtA58KOOkSwjWzSzyLhr7glDELXlB7BW1wiKuclrSE99NLmLQIwt5osvjv6qYxi
jPTU0y1LEKs9mXFjCmwpdjxryttMOPL+3NMjYy0PrauwxtWR1uPS3r+1bhkjtbSs
srx4aV98bFso7NydTPrbGahOHRnY1s7deNq1AzcaYsKV0ASky5cgagmk9qRyfxMd
UBAo4+cxQG2V9ccGO4PR+cuL6JQuLhfxexneFfR+FSbFPCmM9axNBexqi73BL79q
1aOffzSKLc9gS1I7MjXgMwc20K+bDYmnWOsePAJpCIt9Jl3S77AKQYzBWapCXCu0
H+vtVEjvH38fuByNtNTBOonqztw7EFuOAMJWg1vRzWfZyeXSljewdLjw/+jTJYNA
iULuGit9BTfIVwT2jaGfVmjebwy47GqaaisK+BF9/gLAGsG9/sSpfnYPOkjGpAZu
1+5nYnGzx8rqlgdPOmxh0MJiJdbLeg7yJxuFnCTe5X7i4wE7jUUkBGmqnWroiYD0
iCxWU81XQMeJDob6WMw2Cori8ZUHt/oBGz3p33ip/NzPihQrlLqqIIx3zYwpM4vt
H6hYuvJ+/t8PHKDhHR+K
=guqf
-----END PGP SIGNATURE-----

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


Mime
View raw message