Controlling the memory usage within your application

Question:

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.

Answer:

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 gre.walk_pool() function:
https://support.cranksoftware.com/hc/en-us/articles/360057413831-gre-walk-pool

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:
https://support.cranksoftware.com/hc/en-us/articles/360056945652-Storyboard-Engine-Plugin-Options

For example to set the max image cache size to say 16 MB pass the following argument on the sbengine script command line:

-oresource_mgr,image=16M

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.load_image() and gre.dump_resource() functions can be used for this:
https://support.cranksoftware.com/hc/en-us/community/posts/360043496251-How-to-Update-Cached-Images-at-Runtime

0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post