Re: Memory leak with cursors and data structures

"Bernd Schoeller" <[email protected]> Tue, 12 Aug 2008 18:37:17 +0200
Newsgroups gmane.comp.lang.eiffel.gobo.devel
Organization Comerge AG
Message-ID <op.ufr78fvrolvcyz@lcp>
Hi Paul,

it is indeed a "know issue" that GOBO cursors can produce these memory  
leaks. The "solution" is to make sure that the cursor is always off after  
an iteration. That way it is not referenced by the data structure anymore  
and will get garbage collected.

The proper solution would be to introduce weak references into the Eiffel  
language. I am not sure if there is any work on this as part of ECMA.

Bernd

On Mon, 11 Aug 2008 20:41:31 +0200, Paul Bates <[email protected]> wrote:

> We've detected a memory leak when using gobo data structure cursors that
> do not run to the end, and currently there is no way to clean them up
> nicely.
>
> Take the following code
>
> f (a_list: !DS_LINEAR [?ANY])
>    local
>      l_cursor: DS_LINEAR_CURSOR [?ANY]
>      l_stop: BOOLEAN
>    do
>      l_cursor := a_list.cursor
>      from l_cursor.start until l_cursor.after or l_stop loop
>        l_stop := l_cursor.item = Void
>        if not l_stop then
>          l_cursor.forth
>        end
>      end
>    end
>
> Passing a linear structure to 'f' where any item is Void will cause the
> leak because the list never goes 'off'. We cannot call
> DS_TRAVERSABLE.remove_traversing_cursor and it is not a good idea to do
> so because it may have not been added the the managed list or cursors,
> given the current lazy-eval implementation.
>
> The current solution is to run out the cursor in another loop or run out
> the cursor in the original loop but conditionally process the loop's
> functional body. Neither of which look that nice.
>
> Best,
> Paul.
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's  
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great  
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the  
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> gobo-eiffel-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/gobo-eiffel-develop



-- 
Bernd Schoeller, PhD, CTO
Comerge AG, Technoparkstrasse 1, CH-8005 Zurich, Switzerland

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/