Thanks, now let’s see if I can help…
Freeing Memory
You’re doing pretty much the right thing to ensure cleanup:
- Destroy all sprite objects you create. - I assume you’re doing this.
- Make sure any handles used are nil. - I also assume you’re doing this.
- unrequire() the sprite definition (“images.sprites.intro” in the sample above).
- nil the handle referring to the image sheet.
After this, the memory (main and video) will be freed automatically if it is needed.
So far so good.
Measuring Memory
Beware absolutes when measuring memory usage. It is normal for main memory usage to go up and not come back down. This does not imply there is a leak unless the increase continues without end. Rather, this is simply a side-effect of how Lua manages main memory. Likewise measuring video memory usage is a tricky thing. The hardware won’t free video memory right away unless it needs to AND the memory is not in use. (You’re already ensuring this.)
I’m merely giving you this warning so you don’t think a increase is a leak. Only unbounded and continuous increases should be worried about.
Maximum Simultaneous In-Use Sheets
RE: Loading X at a time. X in this case is ‘8’.
Here is where trouble can begin. In my experience and as I understand the functionality of hardware. There is a hard limit to the number of image sheets that can be loaded and retained in memory at any time. This is dependent upon the amount of dedicated video memory. (Someone else may be able to explain this better than I). My only advice here is that you try to keep the number of simultaneously in use sheets as low as possible. Otherwise you’ll find certain devices simply cannot handle your app/game.
Remote?
You lost me on this last bit. Are you saying you want to deliver your app with a small set of sheets and download more? I think the answer is no, because it doesn’t seem to fit your original question. However, I can’t quite grasp what you mean by ‘remote’ if that isn’t it.
Please clarify on your use of the word ‘remote’.
Meanwhile, sorry for the long answer, but I hope it helps a little.