james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Brewin" <sbre...@synsys.com>
Subject RE: [jira] Commented: (JAMES-248) memory management - finalize/nullify after successful delivery of retrieved MailImpl
Date Thu, 08 Apr 2004 19:48:44 GMT
Richard O. Hammer wrote:
> Generally, all you need to do with a variable name when you are done
> with it is to forget it.  Just let it fall out of scope, while making
> sure of course that your scope is not larger than needed.

Sage advice.

> When I see variables set to null after their use, I think that this
> programmer does not know Java.

One source of this practise is that it was necessary in some dialects of
other languages featuring GC, such as Smalltalk, where those implementations
only supported strong references. In more advanced Smalltalk dialects and
Java we have the ability to use various kinds of weak(er) references which
remove the need to explicitly release a strong reference.

Bottom line. Choose the appropriate kind of reference, manage scope and
leave the garbage collector to do its stuff. Use JVM options to tune the
heap size and GC algorithms as best fits the application. Trying to manage
memory use explicitly works against Java's ability to "write once, run
anywhere" as those explicit choices are static and will be optimised to a
single deployment scenario at best and at worst add unnecessary and
unproductive tasks to the garbage collectors work queue.

-- Steve


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message