|
-
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.
Regards,
Max
-
Re: releasing memory by setting objects to null
Max Erixon <max.erixon@framfab.se> 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
>the page?
Hi Max,
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
too much.
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
do so.
- Larne
Similar Threads
-
Replies: 4
Last Post: 04-14-2006, 09:09 AM
-
By Colin McGuigan in forum Database
Replies: 12
Last Post: 04-15-2002, 07:43 AM
-
Replies: 1
Last Post: 11-27-2001, 06:53 AM
-
Replies: 0
Last Post: 11-02-2001, 04:22 PM
-
By Bob Hines in forum Database
Replies: 7
Last Post: 04-27-2000, 11:14 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks