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
path: root/source
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-07-24 13:26:11 +0300
committerJacques Lucke <jacques@blender.org>2020-07-24 13:26:11 +0300
commit236ca8fbe84575504f6ae80aec63c8059b875ef0 (patch)
tree5a889765ba6363b99b1d27231594592013f3263f /source
parent38863924305367eaae65d9447f8a306b86d6ea44 (diff)
Allocator: make leak detection work with static variables
When definining static variables that own memory, you should use the "construct on first use" idiom. Otherwise, you'll get a warning when Blender exits. More details are provided in D8354. Differential Revision: https://developer.blender.org/D8354
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesdna/intern/CMakeLists.txt1
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt1
-rw-r--r--source/blender/makesrna/intern/makesrna.c12
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c7
-rw-r--r--source/creator/creator.c1
5 files changed, 7 insertions, 15 deletions
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index 0f2761e311e..737ea9a7e12 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -40,6 +40,7 @@ set(SRC
../../blenlib/intern/BLI_memarena.c
../../blenlib/intern/BLI_mempool.c
../../blenlib/intern/hash_mm2a.c # needed by 'BLI_ghash_utils.c', not used directly.
+ ../../../../intern/guardedalloc/intern/leak_detector.cc
../../../../intern/guardedalloc/intern/mallocn.c
../../../../intern/guardedalloc/intern/mallocn_guarded_impl.c
../../../../intern/guardedalloc/intern/mallocn_lockfree_impl.c
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index a6ed705ec67..0b43a5a6653 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -175,6 +175,7 @@ set(SRC
${DEFSRC}
${APISRC}
../../../../intern/clog/clog.c
+ ../../../../intern/guardedalloc/intern/leak_detector.cc
../../../../intern/guardedalloc/intern/mallocn.c
../../../../intern/guardedalloc/intern/mallocn_guarded_impl.c
../../../../intern/guardedalloc/intern/mallocn_lockfree_impl.c
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index b34c324bd91..045d098bf6a 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -5144,7 +5144,10 @@ static void mem_error_cb(const char *errorStr)
int main(int argc, char **argv)
{
- int totblock, return_status = 0;
+ int return_status = 0;
+
+ MEM_initialize_memleak_detection();
+ MEM_set_error_callback(mem_error_cb);
CLG_init();
@@ -5166,12 +5169,5 @@ int main(int argc, char **argv)
CLG_exit();
- totblock = MEM_get_memory_blocks_in_use();
- if (totblock != 0) {
- fprintf(stderr, "Error Totblock: %d\n", totblock);
- MEM_set_error_callback(mem_error_cb);
- MEM_printmemlist();
- }
-
return return_status;
}
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index aa3f11c2515..945d5fd42e4 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -656,13 +656,6 @@ void WM_exit_ex(bContext *C, const bool do_python)
BKE_blender_atexit();
- if (MEM_get_memory_blocks_in_use() != 0) {
- size_t mem_in_use = MEM_get_memory_in_use() + MEM_get_memory_in_use();
- printf("Error: Not freed memory blocks: %u, total unfreed memory %f MB\n",
- MEM_get_memory_blocks_in_use(),
- (double)mem_in_use / 1024 / 1024);
- MEM_printmemlist();
- }
wm_autosave_delete();
BKE_tempdir_session_purge();
diff --git a/source/creator/creator.c b/source/creator/creator.c
index abc443425a8..9268ed15923 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -295,6 +295,7 @@ int main(int argc,
break;
}
}
+ MEM_initialize_memleak_detection();
}
#ifdef BUILD_DATE