Controlling the memory usage within your application
We are using a "flipbook" style animation with 48 frames and are encountering spikes where we run out of RAM. I would like to get some information about how the resources are loaded in Storyboard.
It may be that your image cache is filling up, exhausting the memory over time. With a flipbook style animation, Storyboard will load and cache each of the images successively and unless limited can grow to fill the available memory. Storyboard will attempt to cache all images (and fonts) loaded to improve performance
You can view the cache contents using the
There are several ways to manage the way Storyboard caches images in this instance...
It is recommended to first set an upper bound on the memory size of the image cache that Storyboard can use for an application ( the default is unbounded ) which can be done by passing the resource manager image cache size option:
For example to set the max image cache size to say 16 MB pass the following argument on the sbengine script command line:
The actual value you assign will depend on your application and available memory. The cache manager by default takes the last recently used
lru approach which means when an allocation can't be fulfilled the request will attempt to remove other entries from the cache until it can either fit the request or it fails.
You can take a more active approach to manually pre-loading and then cleaning up by dumping the images once the animation is completed (or the screen is changed). The
gre.dump_resource() functions can be used for this: