Clearing an image sheet from memory

OK, when I’m finished with and image sheet and want to remove it from memory I just nil it out?

[lua]

myImageSheet = nil

[/lua]

Is that it?  Since it is a graphics call instead of a display I don’t use display.remove( ) but is there anything else I need to do to release it from memory?

I believe that should work. You could print out the texture memory used before you nil it, then garbage collect, and then print the texture memory out afterwards and make sure it goes away.

Rob

Thanks Rob.  I tried to run the image sheets through my standard kill function but display.remove( ) tripped up the removal.  I’ll run some tests.

I’m here again with my “If I remember correctly…” replies :smiley:

IIRC, that’s exactly how it works. I did a lot of these graphics tests some time ago.

I also thought about your other post where you talked about creating lots of display objects, each with their own image sheet object (or something along those lines). While that shouldn’t increase the texture memory use at all, it means creating additional tables, which will cost additional memory. But, I was just curious as to why you’d need to create multiple instances of the same sheet instead of just one?

@Xedur - I have a table where certain names call up certain image sheets and their parameters - it makes it easy to change the content of each image sheet as they are still a work in progress (e.g. which sprites will live where for maximum texture packing).  The downside is that each sprite creates a new image sheet. 

I plan to finalize in image sheets in the end but until then I’m using this loose system.  I have some memory leaks between levels and within levels and there are some indicators that it might be sprite related so I’m checking all the boxes.

Image Sheets are not display objects, so they won’t have all the display object methods, like .remove(). They are also designed to have multiple display objects created from a single image sheet and not take up more memory. I’m not sure if we intended for them to be unloaded.

Rob