[Bf-blender-cvs] [af425f3f7a0] blender2.8: DRW: Fix memory leak with dupli objects.

Clément Foucault noreply at git.blender.org
Wed Feb 7 19:12:54 CET 2018


Commit: af425f3f7a08c09f7fbc7076b364fac75163b296
Author: Clément Foucault
Date:   Wed Feb 7 19:15:37 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBaf425f3f7a08c09f7fbc7076b364fac75163b296

DRW: Fix memory leak with dupli objects.

This was caused by dupli's ObjectEngineData that were not free.

This allocates the data using the instance data manager (no alloc/free between frames). Though the data should be treated as not persistent in this case.

===================================================================

M	source/blender/draw/intern/draw_manager.c

===================================================================

diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 909095b8901..6ab6f20013e 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2822,7 +2822,17 @@ ObjectEngineData *DRW_object_engine_data_ensure(
 		return oed;
 	}
 	/* Allocate new data. */
-	oed = MEM_callocN(size, "ObjectEngineData");
+	if ((ob->base_flag & BASE_FROMDUPLI) != 0) {
+		/* NOTE: data is not persistent in this case. It is reset each redraw. */
+		/* Round to sizeof(float) for DRW_instance_data_request(). */
+		const size_t t = sizeof(float) - 1;
+		size = (size + t) & ~t;
+		oed = (ObjectEngineData *)DRW_instance_data_request(DST.idatalist, size / sizeof(float), 16);
+		memset(oed, 0, size);
+	}
+	else {
+		oed = MEM_callocN(size, "ObjectEngineData");
+	}
 	oed->engine_type = engine_type;
 	oed->free = free_cb;
 	/* Perform user-side initialization, if needed. */



More information about the Bf-blender-cvs mailing list