Tag: python
HOWTO increase Blender’s memory cache limit for command line renders
by plouj on Jun.08, 2009, under GNU/Linux, hacks, HOWTO
Blender sequencer gives the ability to optimize rendering of repeated frames by keeping the first result in memory cache and re-using it. Depending on the project, it might be necessary to increase this limit beyond the default 32MB. If the limit is surpassed while rendering a single frame, Blender clears the cache before proceeding to the next frame and the re-renders everything from scratch.
Increasing the cache limit is easy to do in the UI:

This setting is stored in the user’s preference file (~/.B.blend on Linux systems) and, therefore, applies to all projects. However, rendering from the command line requires using the -b argument, which explicitly ignores the user’s preference file. Apart from editing and re-compiling the Blender source code, I found only one way to increase the memory cache limit.
The trick is to use a Python script, like below, to change the user preferences before rendering the scene:
import sys import bpy def main(): bpy.config.sequenceMemCacheLimit=4096 if __name__ == '__main__': main()
Add the script to the command line like this:
./bin/blender -b sample-static-text.blend -P render_settings.py -a
Note that the order of arguments matters because first we need to load the scene (with -b), then change settings through Pythons (using the -P option) and finally render the animation (with -a). Also, you need at least version 2.49a of Blender for this to work.
For reference, here’s is the the source file which hardcodes the 32MB limit:
intern/memutil/intern/MEM_CacheLimiterC-Api.cpp:
...
static intptr_t & get_max()
{
static intptr_t m = 32*1024*1024;
return m;
}
...
