Garbage Collect Delay?

I am trying to figure out why this:
[lua]loadingGroup:removeSelf()
collectgarbage(“collect”)[/lua]
Seems to do nothing as my memory usage stays high for a painfully long time.

where as this:
[lua]loadingGroup:removeSelf()
timer.performWithDelay(1, function() collectgarbage(“collect”) end)[/lua]
Drops my used texture memory almost immediately?

I’m cycling full screen instructional pages and when the user chooses to “skip”, I need this memory back as fast as I can get it. My method works, I just don’t understand why and it bugs me. heh [import]uid: 9187 topic_id: 4037 reply_id: 304037[/import]

removeSelf isn’t necessarily instant… especially if it’s an item with physics. it waits until it’s outside of the Box2D step, to safely remove the body (presumably before the next enterFrame) [import]uid: 6645 topic_id: 4037 reply_id: 12392[/import]

In my case we are talking about plain images. No physics. removeSelf() works great when memory is not in demand, I can wait the 10-30sec for it to clear most of the time. However, in this case I need that memory ASAP.

I am more concerned about why collectgarbage(“collect”) seems to do nothing when called directly after removeSelf() but when put on even a single millisecond delay, it works like a charm. [import]uid: 9187 topic_id: 4037 reply_id: 12394[/import]

try this then

[lua]obj.parent:remove(obj)[/lua]

my guess is removeSelf might not do it immediately because it is also the function used for phsyics items. so probably just flags the item for removal and does it at the end of the enterframe [import]uid: 6645 topic_id: 4037 reply_id: 12395[/import]

wow, very interesting. I’m going to have to implement that 1 millisecond delay in my app and see if it makes any difference performance-wise. [import]uid: 7849 topic_id: 4037 reply_id: 12562[/import]