Prev Previous Post   Next Post Next
Old 03-01-2011, 12:03 PM
Redwolfhome's Avatar
Redwolfhome Redwolfhome is offline
Junior Member
Join Date: Mar 2010
Location: Germany
Posts: 91
Default A new and better way to save memory

I think some of you (Zen X-Fi II developers) know this problem. We want to save memory because the zen doesnt have enough!
So maby we create a second load which close the first loaded images and load new ones. But in our Pingus game we have the problem that there also was not enough memory.
So i have try a few ways and was successful. I have found a function which gives you the currentyl used memory. It is called gcinfo() and so you can get the currently used memory like this way:
So i have try to open a image and close it and my result was that the zen doesnt delete the memory which was used before. But then I have found another function it is called collectgarbage()! This function delete all the unused cache and garbage and after a few tests I can say that the function is very useful.
So just close all images and then just put at the end collectgarbage()!
And I have asked myself why is there a function which is called screen.clear() and nobody used this function? So i have test this function and it also doesnt happend anythink. But after i run the garbage collector there was a little bit more memory free

So my result is that you have to close a image with
or with:
exampleimage = nil;
but this way doesnt get another effect:
exampleimage = nil;
Try it yourself and you will be lucky with the new way to save memory
And another really good think is that you can close all images and put this at the end of your file:
And so all garbage will be deleted

Reply With Quote

Advertisement [Remove Advertisement]


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 07:16 PM.