cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Johnston <>
Subject Re: cforms showForm and memory leaks: quick question
Date Fri, 04 May 2007 21:39:25 GMT
On Fri, 04 May 2007 22:33:31 +0200, Dev at weitling <> wrote:
>>> I use flow to show a cform (see code below), and I'm wondering if
>>> I need to "terminate" each function in flow in a "clean" way to avoid
>>> memory leaks (after the form.showForm(...) provide some action
>>> (redirect the user)
>> I think this is not necessary.  The form.showForm() call creates a
>> continuation, which keeps a handle on any objects in memory.  After a
>> given period (configured in the xconf) the continuation will be
>> automatically expired, at which point any objects it holds will be
>> garbage collected.  As long as all those objects are things you're
>> willing to have in memory for the lifetime of the continuation, you
>> can just leave it be.
> Yesno. As far as I understood used Avalon components as well as some
> Java objects (e.g. those with that nice "dispose" method) should be put
> back or disposed before a continuation is created.

Yes Florian, that's certainly true.  Any objects that need to have a special cleanup method
called (.dispose() for Avalon components, .close() for IO streams, etc.) need to have that
method called *before* the continuation is suspended, since there's no guarantee it will ever
be resumed.

I should also mention that if there are any objects stored as JS variables that you know you
won't need anymore, and don't want to wait for the continuation to expire before they get
garbage collected, you can set the variable to null to release the reference immediately:

   var obj = new InsanelyHeavyObject();
   cocoon.sendPageAndWait("pipeline", {obj:obj});
   obj = null; // releases reference, can be GC'd

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message