james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Serge Knystautas <ser...@lokitech.com>
Subject Re: [jira] Commented: (JAMES-248) memory management - finalize/nullify after successful delivery of retrieved MailImpl
Date Thu, 08 Apr 2004 17:17:40 GMT
Noel J. Bergman wrote:
>>>and [Java] certainly does not guarantee that they will run
>>>before Java decides to garbage collect that object.
> 
>>I believe there is a guarantee that the finalize() method will be
>>called on an object before it is garbage collected
> 
> You mis-understood.  Rephrasing, you cannot count on Java to call the
> finalize method if it has not has not yet decided to garbage collect the
> object.

I would explain it that you cannot guarantee when Java will decide to 
garbage collect /this/ object.  Even an explicit call to System.gc() does:

"Calling the gc method suggests that the Java Virtual Machine expend 
effort toward recycling unused objects in order to make the memory they 
currently occupy available for quick reuse. When control returns from 
the method call, the Java Virtual Machine has made a best effort to 
reclaim space from all discarded objects."

So just because you no longer reference it in your code will System.gc() 
get called.  You could try to call System.runFinalization().  However I 
would suggest switching to an active way of cleaning up resources rather 
than relying on finalize().

-- 
Serge Knystautas
President
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. sergek@lokitech.com

---------------------------------------------------------------------
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