Preventing Blender from crashing
This guide explains what precautions can be taken to prevent Blender from crashing. Blender’s docs also provide a useful page, that in particular includes a section on Help! My script crashes Blender: Gotchas .
Executing Python Scripts via Command Line
Blender is usually (and best) started from a console,
see Scripting in Blender.
Executing a python script in Blenders GUI over and over again may
lead to unwanted leakage, caching and unintentionally influencing Blender’s state.
Therefore it is recommended to always execute a python script with a new
instance of Blender. This can be done by using the --pyhton flag.
blender --python /path-to-python-file/file.py
For Windows and Mac change the blender call to the corresponding call listed
in Scripting in Blender.
Executing Blender in the background
If you don’t need Blender’s GUI, for example when directly rendering from a Python script, you may want to run Blender in the background to save extra memory.
blender --background --python /path-to-python-file/file.py
For Windows and Mac change the blender call to the corresponding call listed
in Scripting in Blender.
Reducing the number of Blender objects
In our experience Blender is better at handling fewer objects with dense meshes
compared to many objects with coarse meshes. Therefore it might make sense
to join multiple objects into one object. Nets can be joined in
NetCollection s. Halfedge objects can be joined by using the
function union().
You can manually join objects in Blender by selecting them and pressing Ctrl + J.
Alternatively you do this via script using the function join()
that joins meshes or objects with mesh data.
Preventing Animations to Crash during Rendering
In addition to the tips and tricks above you can find more hints for more stable rendering of animations in the Rendering guide under Animation.
Debugging when Blender crashed
If Blender still crashes, Blender’s command line tool offers a lot of options for debugging and getting more informative debugging messages. Run
blender --help
to get an overview.
For Windows and Mac change the blender call to the corresponding call listed
in Scripting in Blender.