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:
authorClément Foucault <foucault.clem@gmail.com>2018-02-07 21:15:37 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-02-07 21:15:55 +0300
commitaf425f3f7a08c09f7fbc7076b364fac75163b296 (patch)
treef6efee3aeac82a417183381c2c453a228311d470 /source/blender/draw
parent8a2f93b2aba76a6c1c065a08d14e414db8cb597e (diff)
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.
Diffstat (limited to 'source/blender/draw')
-rw-r--r--source/blender/draw/intern/draw_manager.c12
1 files changed, 11 insertions, 1 deletions
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. */