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>2015-02-17 15:27:15 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-03-13 15:38:03 +0300
commit0e18a5643239203385258b7d64f2d6b15594fa46 (patch)
treee12298d4611418f4249197ef8b3e4adfc530fd85 /source/blender/blenkernel/intern/object.c
parent79393cb7a2dfef3bd7205b1a68558aaba2f2b5da (diff)
Cycles: Free caches used by the synchronized objects
Issue this commit is addressed to is that particle system and particle modifier will contain caches once derived mesh was requested and this cached data will never be freed. This could easily lead to unwanted memory peaks during synchronization stage of rendering. The idea is to have RNA function in object which would free caches which can't be freed otherwise. This function is not intended to deal with derived final since it might be used by other objects (for example by object with boolean modifier). This cache freeing is only happening in the background rendering and locked interface rendering. From quick tests with victor file this change reduces peak memory usage by command line rendering by around 6% (1780MB vs. 1883MB). For rendering from the interface it's about 12% (1763MB vs. 1998MB). Reviewers: campbellbarton, lukastoenne Differential Revision: https://developer.blender.org/D1121
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 8a6c6414266..d63e2516805 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -329,6 +329,45 @@ void BKE_object_free_derived_caches(Object *ob)
BKE_object_free_curve_cache(ob);
}
+void BKE_object_free_caches(Object *object)
+{
+ ModifierData *md;
+ short update_flag = 0;
+
+ /* Free particle system caches holding paths. */
+ if (object->particlesystem.first) {
+ ParticleSystem *psys;
+ for (psys = object->particlesystem.first;
+ psys != NULL;
+ psys = psys->next)
+ {
+ psys_free_path_cache(psys, psys->edit);
+ update_flag |= PSYS_RECALC;
+ }
+ }
+
+ /* Free memory used by cached derived meshes in the particle system modifiers. */
+ for (md = object->modifiers.first; md != NULL; md = md->next) {
+ if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
+ if (psmd->dm != NULL) {
+ psmd->dm->needsFree = 1;
+ psmd->dm->release(psmd->dm);
+ psmd->dm = NULL;
+ update_flag |= OB_RECALC_DATA;
+ }
+ }
+ }
+
+ /* Tag object for update, so once memory critical operation is over and
+ * scene update routines are back to it's business the object will be
+ * guaranteed to be in a known state.
+ */
+ if (update_flag != 0) {
+ DAG_id_tag_update(&object->id, update_flag);
+ }
+}
+
/* do not free object itself */
void BKE_object_free_ex(Object *ob, bool do_id_user)
{