On Wed, 4 Apr 2001, Danny Angus wrote:
>
> I see from the archive that the memory "leak" effect is caused by session
> handlers creating a session for each.. well.. session.
>
> My question is how can I take charge of this, i cant seem to turn off
> session tracking for servlets. Simply removing the interceptors from
> server.xml doesn't help.
>
> I find that after about 820,000 hits in six hours, :-), I get an out of
> memeory exception, I could avoind this if I knew how to destroy sessions, or
> not create them at all, or even just fine tune their time-to-live.
>
> I haven't found my way round this bit of the source yet, so *any* tips will
> be greatfully recieved, however obvious they may be to others...
>
> danny
>
>
(Late response, but still hopefully useful)
There are two basic strategies you should consider:
* Set the default session timeout to something much smaller than
the default 30 minutes. This is done using the <session-config>
element in the web.xml file.
* Don't create sessions at all if you are not going to use them.
In a servlet, this is done by simply never calling request.getSession().
JSP pages default to creating sessions unless you tell them not to
with a page directive:
<%@ page session="false" %>
It sounds like that latter might be what you are really after.
If you are not creating sessions, but still getting OutOfMemoryException
problems, then there is something else wrong with your code that is
allocating memory but not releasing it.
Craig McClanahan