Carsten Ziegeler wrote:
The last days showed that we have a lot of potential memory leaks, see
[1] http://marc.theaimsgroup.com/?t=107330680600002&r=1&w=2 and
[2] http://marc.theaimsgroup.com/?t=107355695400003&r=1&w=2
This is caused by the simple fact that in some cases the recycle() method of a Recyclable component is not called (see [2] for some details about that).
Now, I see two solutions: 1) Ensure that recycle() is called by implementing Disposable() for each Recyclable component and call recycle() from there. This is a lot of hand work to do, but should work
2) Ensure that the container always calls recycle().
Now, obviously 2) is the easier solution as this should only be one
or two lines two write :)
But the problem is, that you Pooling (or Recyclable) is not guaranteed to
be available in every container and even if it is available you don't
know if the container pools your component (I think this is correct,
if not please correct me). So, theoretically 2) is not a solution.
Any other ideas?
Fortress uses the Lifecycle Extensions package in Avalon--which provides Accessors and Creators. The Creators handle the one time start up and shutdown semantics. You can extend it here.
However I think that it is just as important to realize the the Recyclable/
Resettable interfaces *never* made the promise that it would always be
called. Expecting that is expecting a contract that does not exist. It
would have been better to design with that realization. Nevertheless we
are here, and we need to do something.
So +1 for 1) : we should not twist the existing contracts because we may have misinterpreted them in some cases.
I know it's a dedious work, but let's check our Recyclable components and fix them where needed.
Sylvain
-- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects } Orixo, the opensource XML business alliance - http://www.orixo.com
