releasing memory by setting objects to null
We are using alot of objects on a couple of jsp pages. Would it improve performance
to set all these objects to null at the end of the page?
I know that the garbage collector probably will take care of this but will
it do it's work easier and faster if you set all the objects to null??
To improve performance and reduce the load on ASP pages this is very useful.
Re: releasing memory by setting objects to null
Max Erixon <firstname.lastname@example.org> wrote:
>We are using alot of objects on a couple of jsp pages. Would it
>improve performance to set all these objects to null at the end of
To some extent this depends on what version of the Java VM you're
working with, but as a general rule I wouldn't think this would help
The garbage collector will reallocate space when it can prove that
there is no reference to that space. So in the following code:
<% String foo = new String("Hello"); %>
.... rest of page ...
<% foo = null; %>
The string can be freed up as soon as foo is no longer pointer to it.
However, when the page ends the variable foo will go out of scope
anyway, at which point there will be no reference to the string left
and it can be freed.
Really the best thing you can do on the performance front is move to
the latest version of the Java VM. Recent versions include a
'generational garbage collector' which is optimized for dealing with
lots of small, short-lived objects.
The only other thing I can suggest is that you limit what you are
storing in sessions, and try to expire sessions as soon as possible.
Everything in the session stays in memory, and typically a session may
last for half an hour after the user has left the site. Most
application servers will allow you to lower this timeout, or if you
can make your users log out you can expire the session as soon as they
Last Post: 04-14-2006, 10:09 AM
By Colin McGuigan in forum Database
Last Post: 04-15-2002, 08:43 AM
Last Post: 11-27-2001, 07:53 AM
Last Post: 11-02-2001, 05:22 PM
By Bob Hines in forum Database
Last Post: 04-27-2000, 12:14 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center