Awesome, great improvements. keep it up champ! [import]uid: 19620 topic_id: 9163 reply_id: 34326[/import]
Update:
Testing Director 1.3 (thanks Ricardo) with Corona Version 2011.484 (2011.4.12) on iPhone 3GS, and iPad2 (various iOS versions) went well. No issues to report.
I’ll post again after testing on iPhone 4, iPod Touch 4 (various iOS versions)
Side Note: I am using Director 1.3 but also using cleangroup.lua (http://jonbeebe.tumblr.com/post/3760389212/proper-group-cleaning-in-corona-script-download) to do various cleanup tasks of non Director related Groups as well as other Objects, Listeners, etc…
Best wishes,
Paul Allan Harrington
http://www.pahgroup.com [import]uid: 14336 topic_id: 9163 reply_id: 34330[/import]
isn’t it true that with the latest updates to corona, using remove:self() to a group now properly removes it and all the child objects? Is there any reason to use the CleanGroup module anymore? [import]uid: 19620 topic_id: 9163 reply_id: 34392[/import]
Personally, I don’t believe there’s a reason for CleanGroups() anymore, with this core Corona update.
I have modified my own version of Director (1.2) to utilize this recent API (display.remove()
) and it appears to be working perfectly. In testing over the course of a few days, I haven’t noticed any memory-leak-related lag using this method instead of CleanGroups().
However, I haven’t gone to serious lengths to test it. I simply put a repeating function in my “main.lua” to collect garbage and print out both texture memory and Lua memory (this code was borrowed from Tom at Ansca). As I move around in different scenes and menus, it doesn’t appear that I’m experiencing any memory leaks, but somebody would probably need to test this more thoroughly to be 100% sure.
Brent Sorrentino
[import]uid: 9747 topic_id: 9163 reply_id: 34396[/import]
If i am using the director class to print to the terminal the system memory, but im not using his method to clean my groups and such, will the printed memory still be accurate of how much memory im using? I feel like my game has a pretty bad memory leak, i start at my main menu with 276, then go to a level which puts me at 335, then when i go back to my main menu im at 342… [import]uid: 19620 topic_id: 9163 reply_id: 34398[/import]
If it’s true that you don’t need to clean the groups anymore (using a recursive function), I wonder why CoronaUI has the same cleanGroups function with additional listeners removal? [import]uid: 8556 topic_id: 9163 reply_id: 34402[/import]
When you return to your menu, does the memory ever drop back to “normal” amounts? Or does it continually hover around 342? If it does, you probably have a memory leak not related to Director…
I assume you tried using the latest CleanGroups() in Director 1.3? Despite the new improvements to this function, I still don’t think there’s any substitute for *manually* cleaning up your listeners, at the bare minimum. Even though the new function does this (apparently), I still make sure that all of my listeners and external references to scene objects are removed before I exit the scene.
Sometimes tedious, yes, but it’s worth the effort. Better than trying to seek out a pesky memory leak when your game is 90% finished.
[import]uid: 9747 topic_id: 9163 reply_id: 34404[/import]
@Ricardo: If it’s true that you don’t need to clean the groups anymore (using a recursive function), I wonder why CoronaUI has the same cleanGroups function with additional listeners removal?
Good question Ricardo! Perhaps they haven’t gotten around to updating it yet? If I recall, Tom at Ansca said the updates to the internal removeSelf() functionality *should* free up listeners too… because it clears the objects recursively and thus “un-links” those listeners and makes them eligible for Lua garbage collection.
I wish we could get a definitive answer on this, but it looks like thorough testing is the only way to be sure. [import]uid: 9747 topic_id: 9163 reply_id: 34406[/import]
I did a test here:
print ( "Texture: " .. system.getInfo( "textureMemoryUsed" ) )
--
local imagem, quadrado, grupo
--
local function loadImages ()
imagem = display.newImageRect( "car.jpg", 200, 100 )
quadrado = display.newRect( 200,200,200,200 )
quadrado:setFillColor( 0,200,100 )
grupo = display.newGroup()
grupo:insert( imagem )
grupo:insert( quadrado )
end
--
loadImages ()
print ( "Texture: " .. system.getInfo( "textureMemoryUsed" ) )
grupo:removeSelf()
collectgarbage( "collect" )
print ( "Texture: " .. system.getInfo( "textureMemoryUsed" ) )
--
loadImages ()
print ( "Texture: " .. system.getInfo( "textureMemoryUsed" ) )
imagem:removeSelf()
imagem = nil
quadrado:removeSelf()
imagem = nil
collectgarbage( "collect" )
print ( "Texture: " .. system.getInfo( "textureMemoryUsed" ) )
The result was:
Copyright (C) 2009-2010 A n s c a , I n c .
Version: 2.0.0
Build: 2011.484
Texture: 0
Texture: 524288
Texture: 0
Texture: 524288
Texture: 0
It seems to be cleaning this group properly, but it’s a simple group without subgroups and listeners. I will test it better later. [import]uid: 8556 topic_id: 9163 reply_id: 34410[/import]
Changed the test:
print ( "Texture: " .. system.getInfo( "textureMemoryUsed" ) )
--
local imagem, quadrado, grupo
--
local function loadImages ()
imagem = display.newImageRect( "car.jpg", 200, 100 )
--
quadrado = display.newRect( 200,200,200,200 )
quadrado:setFillColor( 0,200,100 )
--
grupo = display.newGroup()
grupo:insert( imagem )
grupo:insert( quadrado )
--
print ( "Texture: " .. system.getInfo( "textureMemoryUsed" ) )
end
--
local function showInfo ()
print("imagem: " .. type(imagem))
print("quadrado: " .. type(quadrado))
print("grupo: " .. type(grupo))
--
collectgarbage( "collect" )
--
print ( "Texture: " .. system.getInfo( "textureMemoryUsed" ) )
end
--
loadImages ()
grupo:removeSelf()
showInfo ()
--
loadImages ()
imagem:removeSelf()
imagem = nil
quadrado:removeSelf()
quadrado = nil
showInfo ()
And the result:
Copyright (C) 2009-2010 A n s c a , I n c .
Version: 2.0.0
Build: 2011.484
Texture: 0
Texture: 524288
imagem: table
quadrado: table
grupo: table
Texture: 0
Texture: 524288
imagem: nil
quadrado: nil
grupo: table
Texture: 0
Now I can see that grupo:removeSelf() doesn’t nil the variables. [import]uid: 8556 topic_id: 9163 reply_id: 34411[/import]
Thanks for doing these tests Ricardo!
“group:removeSelf()” might not explicitly “nil” the children contained within, but logically those should be eligible for Lua garbage collection following the function call, unless they are somehow being locked/held by an external reference. Would you agree with this?
You might also try display.remove(object/group)
. I actually changed every occurrence of “removeSelf()” in my entire game to this, since it combines the power of that API with a pre-check that the object/group ~= nil.
[import]uid: 9747 topic_id: 9163 reply_id: 34416[/import]
ricardo,
Can you give a quick explaination on how to set up a pop up director scene, as well as how to use the PopUp call?
[import]uid: 5317 topic_id: 9163 reply_id: 34456[/import]
I got the popUp working well! Nice job on that, very handy.
The only problem is that transitions that are running are not paused. I don’t even know if it is possible to do, but if it is, that would be the bees knees. [import]uid: 5317 topic_id: 9163 reply_id: 34591[/import]
You could use the Transitions Manager, i believe its available in the code exchange, its awesome, you can pause and resume or cancel all transitions with one line of code. [import]uid: 19620 topic_id: 9163 reply_id: 34592[/import]
I tested v1.3 with the windows version in the simulator, I made a simple script to load a level, create and destroy thousands of objects, then go back to the main menu. Then it repeats that cycle 100 times. I monitored the texture and Lua memory after each cycle.
It seems to work just fine - I didn’t detect any problems with memory leaks. That’s all I was testing for in this case.
I should point out I was manually cancelling all listeners and timers in my clean() function.
I monitored texture memory and Lua memory, and it went up a bit at first, then stayed pretty steady, moving up and down a bit. I think that’s simply related to timers, as per my post here:
[import]uid: 49372 topic_id: 9163 reply_id: 34602[/import]
Guys, check this out: http://rauberlabs.blogspot.com/2011/05/news.html [import]uid: 8556 topic_id: 9163 reply_id: 35167[/import]
Any news on 1.3? [import]uid: 10478 topic_id: 9163 reply_id: 38085[/import]
I’ve been testing Director 1.3 from the above link for the past few days and have to say that I’m pretty impressed by it. I’ve been using it in my latest game which is under development and Director 1.3 has performed very well.
When will it be finalised? Or is that it?
– Chris
[import]uid: 33866 topic_id: 9163 reply_id: 40819[/import]
Director Class 1.3 Preview - http://www.youtube.com/watch?v=MZdD_CnydJ4 [import]uid: 8556 topic_id: 9163 reply_id: 41612[/import]