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:
authorJulian Eisel <julian@blender.org>2021-12-06 19:46:21 +0300
committerJulian Eisel <julian@blender.org>2021-12-07 13:47:06 +0300
commit4312cb854517ded8a576c2b53c8e92258eed7cce (patch)
tree7ca0d50e37685dec1eaa9d056cda10f12340adfb /source/blender
parentcd494087c1f214771d952d110ed2a1a685e7ec28 (diff)
Fix memory leak when loading large asset libraries
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/space_file/filelist.c9
1 files changed, 9 insertions, 0 deletions
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);
}