Garbage collection for images?

Hi,

I am working on a project that displays full-screen images. I was wondering if I need to have each image removed from memory, once the user chooses a different image to look at. Here is an example of what I have (and there are almost 60 images in this app)

local myImages = {
“DHS-logo.jpg”,
“Book-Cover.jpg”,
“also-by.jpg”,

Would I need to add code somewhere to tell each image to flush itself from memory? If so, can someone give an example? Thank you. [import]uid: 10083 topic_id: 2751 reply_id: 302751[/import]

Yes, you need to clear your memory! The easiest way IMHO is to use the awsome Director Class that is available here on the website (created by one the users here Ricardo Gruber(??)). If you use it the way it’s documented (insert all graphics into a display group) it will handle clearing memory for you when you change “scenes.”

Otherwise you need to perform:
object.removeSelf()
object = nil

See Corona docs for explanation of proper display memory management.

-Mark [import]uid: 9189 topic_id: 2751 reply_id: 9229[/import]

Hi Mark,

Thanks for the reply. I’ll try the Director Class and your suggestion. Much appreciated. [import]uid: 10083 topic_id: 2751 reply_id: 9284[/import]

But what is the next step after inserting all images in a group? However, I’m displaying Scranton images and one the user clicks on one image, I want to remove. In other words, lots of images moves straightway without being touched so the will just cross the screen and continue so how I should remove these images?? Thanks
Please be patient in case my it’s a stupied question as I’m new here and [import]uid: 11038 topic_id: 2751 reply_id: 10378[/import]

You could put the name of all your images in a data statement then each time an image is to be shown you load the next file name into a variable then use this variable as your image name on your display.newImage code
Then when you ready for next image code goes to a function to clear memory then reads next file name from data
That way you have one function that will load each image one at a time and one function that clears memory and then your data statements
If you need an example I’ll throw something together for you when I get home [import]uid: 7911 topic_id: 2751 reply_id: 10394[/import]

Thanks man for your support. Please be patient with me. Thats what im doing right now

local createNewObject = {}
function createNewObject:timer( event )
local indexFileNumber = math.random (1, 15)

–local balloonObject = display.newText( indexFileNumber, pointerX , pointerY, native.systemFont, 15 )
–balloonObject:setTextColor( 255,255,255 )
local balloonObject = display.newImage( “balloon”…indexFileNumber…".png", -65,-65 )
balloonObject.x = objectX(320)
physics.addBody(balloonObject, {density=0.0, bounce = 0.2, radius=27, friction=0.0 })
balloonObject:addEventListener( “touch”, moveBalloon )
end

timer.performWithDelay(200, createNewObject, 0)

with regard to to the clicked balloons i’m cleaning by using balloon.parent:remove( balloon ) , im using a listener and from there im cleaning.

but my problem how to delete/clean the undeleted balloons

Thanks [import]uid: 11038 topic_id: 2751 reply_id: 10403[/import]