I am having major memory problems using the roScreen.
My app requires me to have many images loaded from the web and the device that are used frequently. This means I have to load them in to memory as a roBitmap, which uses a lot of memory. When I am done with the bitmaps I set them to invalid so that I can free up memory. However it seems that this does not clear up the memory right away. Is there some way that I can call the garbage collector through code? What memory management tools are there other then r2d2_bitmaps and running the garbage collector from the debug console?
I have to get this figured out because i can't just have my app randomly crash because the Roku is out of memory.
You can run the garbage collector from code by calling RunGarbageCollector(). That does not, however, in my experience, free up graphics memory. How are you creating your roBitmaps? They will only be unloaded from memory, if you remove all references to them, so setting the original bitmap to invalid will only work if you haven't referenced that bitmap from any other object in your code. If you're not already, you may want to consider using the roTextureManager to manage your bitmaps, as it does a lot of the caching, loading and unloading legwork for you.
RunGarbageCollector() not freeing up graphics memory is rather annoying, I am de-allocating and re-allocating memory rather quickly in some cases so I was hoping to force the garbage collector to run in between the de-allocating and re-allocating to prevent crashing. roTextureManager looks really promising so I will be implementing that, Hopefully that will be enough to stop the app from crashing from running out of memory.
"boomAlex" wrote: RunGarbageCollector() not freeing up graphics memory is rather annoying, I am de-allocating and re-allocating memory rather quickly in some cases so I was hoping to force the garbage collector to run in between the de-allocating and re-allocating to prevent crashing.
You also need to leave some headroom. For a 2XS with 39mb of graphics memory I would never go over 35mb used for any reason and preferably less than that. R2D2 is your only friend with this.
then call SwapBuffers() or finish() if the screen is single buffered. That should free up the unloaded texture. If you are using he TextureManager, then you might also need to unload the bitmap from texture manager: