Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-11-09 18:14:15 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-11-09 19:53:02 +0300
commit549468365157a075949f2d4b8d9496ff719cefbf (patch)
treef564368fe509f46e4ec13b350b62aaace571c093 /intern/cycles/blender/blender_session.cpp
parentcbbf991f62b7f1546771a71b3b9f14a46d1b6b61 (diff)
Cycles: Free Blender side data as soon as we don't need it
Currently this is possible after built-in images are loaded in memory. Allows to save memory used by dependency graph and copy-on-write. In practice this lowers peak system memory usage from 52GB to 42GB on a production file of spring 03_035_A.lighting. Note, that this only applies to F12 and command line renders. Bigger note, that this optimization is currently only possible if there are no grease pencil objects to be rendered.
Diffstat (limited to 'intern/cycles/blender/blender_session.cpp')
-rw-r--r--intern/cycles/blender/blender_session.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 28b0f4faf63..17da8b43d29 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -470,6 +470,11 @@ void BlenderSession::render(BL::Depsgraph& b_depsgraph_)
&python_thread_state);
builtin_images_load();
+ /* Attempt to free all data which is held by Blender side, since at this
+ * point we knwo that we've got everything to render current view layer.
+ */
+ free_blender_memory_if_possible();
+
/* Make sure all views have different noise patterns. - hardcoded value just to make it random */
if(view_index != 0) {
scene->integrator->seed += hash_int_2d(scene->integrator->seed, hash_int(view_index * 0xdeadbeef));
@@ -1406,4 +1411,16 @@ void BlenderSession::update_resumable_tile_manager(int num_samples)
session->tile_manager.range_num_samples = range_num_samples;
}
+void BlenderSession::free_blender_memory_if_possible()
+{
+ if (!background) {
+ /* During interactive render we can not free anything: attempts to save
+ * memory would cause things to be allocated and evaluated for every
+ * updated sample.
+ */
+ return;
+ }
+ b_engine.free_blender_memory();
+}
+
CCL_NAMESPACE_END