[Bf-blender-cvs] [4312cb85451] master: Fix memory leak when loading large asset libraries

Julian Eisel noreply at git.blender.org
Tue Dec 7 11:48:27 CET 2021


Commit: 4312cb854517ded8a576c2b53c8e92258eed7cce
Author: Julian Eisel
Date:   Mon Dec 6 17:46:21 2021 +0100
Branches: master
https://developer.blender.org/rB4312cb854517ded8a576c2b53c8e92258eed7cce

Fix memory leak when loading large asset libraries

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

M	source/blender/editors/space_file/filelist.c

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

diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 6593894d9a6..a580cf672f4 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1624,6 +1624,9 @@ static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdat
     preview->icon_id = BKE_icon_imbuf_create(imbuf);
   }
 
+  /* Move ownership to the done queue. */
+  preview_taskdata->preview = NULL;
+
   BLI_thread_queue_push(cache->previews_done, preview);
   atomic_fetch_and_sub_z(&cache->previews_todo_count, 1);
 
@@ -1633,6 +1636,12 @@ static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdat
 static void filelist_cache_preview_freef(TaskPool *__restrict UNUSED(pool), void *taskdata)
 {
   FileListEntryPreviewTaskData *preview_taskdata = taskdata;
+
+  /* In case the preview wasn't moved to the "done" queue yet. */
+  if (preview_taskdata->preview) {
+    MEM_freeN(preview_taskdata->preview);
+  }
+
   MEM_freeN(preview_taskdata);
 }



More information about the Bf-blender-cvs mailing list