Memory leak with cursors and data structures

Paul Bates <[email protected]> Mon, 11 Aug 2008 11:41:31 -0700
Newsgroups gmane.comp.lang.eiffel.gobo.devel
Message-ID <[email protected]>
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=/