The listView:cleanUp() code in the tableView.lua file does not properly free up all of the resources in the list. It is still calling the old item:remove(i) code instead of recursively removing everything in the group.
First, I suggest that a new API call be added to properly recurse through a Group to remove all of the items in it. The group:removeSelf() call does NOT recurse to the children items. This is a huge problem with much of the user-submitted code I have been looking at. People just don’t really seem to understand memory management (even with the good articles available). I think Corona could be made more stable by addressing some of this in the core API.
In any case, I added the following function to tableView.lua (taken from the Director project)
[lua]local function removeGroup( curGroup, level )
level = level or 0
if curGroup.numChildren then
while curGroup.numChildren > 0 do
removeGroup( curGroup[curGroup.numChildren], level+1 )
end
if level > 0 then
curGroup:removeSelf()
end
else
curGroup:removeSelf()
curGroup = nil
return
end
end[/lua]
then I modified the listView:cleanUp function to look like this:
[lua]function listView:cleanUp()
Runtime:removeEventListener(“enterFrame”, moveCat )
Runtime:removeEventListener(“enterFrame”, scrollList )
Runtime:removeEventListener( “enterFrame”, showHighlight )
Runtime:removeEventListener(“enterFrame”, trackVelocity)
local i
for i = self.numChildren, 1, -1 do
self[i]:removeEventListener(“touch”, newListItemHandler)
end
removeGroup(self)
listView = nil
end[/lua]
This removed the memory leak that was occurring. I didn’t see a separate forum for List Views, so hopefully this is the correct place to report this. [import]uid: 12529 topic_id: 6675 reply_id: 306675[/import]