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/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-10-03 13:12:22 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-10-03 13:12:22 +0300
commite5387eef1890b7af7320455cccf68303ebecb086 (patch)
tree5997914be2844e3b62e2b7379801d25eea5537b0 /intern
parent8d26705b3e4e780145d43cfde0c1a2c302c425e0 (diff)
parentd2da3af073a63b6ae25119ebbd2e0d3c9a1b6823 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'intern')
-rw-r--r--intern/guardedalloc/CMakeLists.txt5
-rw-r--r--intern/guardedalloc/intern/mallocn.c7
2 files changed, 12 insertions, 0 deletions
diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt
index 10ed4287185..7f648cff27c 100644
--- a/intern/guardedalloc/CMakeLists.txt
+++ b/intern/guardedalloc/CMakeLists.txt
@@ -53,6 +53,11 @@ if(WIN32 AND NOT UNIX)
)
endif()
+# Jemalloc 5.0.0+ needs extra configuration.
+if(WITH_MEM_JEMALLOC AND ("${JEMALLOC_VERSION}" VERSION_GREATER_EQUAL "5.0.0"))
+ add_definitions(-DWITH_JEMALLOC_CONF)
+endif()
+
blender_add_lib(bf_intern_guardedalloc "${SRC}" "${INC}" "${INC_SYS}")
# Override C++ alloc, optional.
diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c
index a95cc9163c4..8c17da853e5 100644
--- a/intern/guardedalloc/intern/mallocn.c
+++ b/intern/guardedalloc/intern/mallocn.c
@@ -37,6 +37,13 @@
#include "mallocn_intern.h"
+#ifdef WITH_JEMALLOC_CONF
+/* If jemalloc is used, it reads this global variable and enables background
+ * threads to purge dirty pages. Otherwise we release memory too slowly or not
+ * at all if the thread that did the allocation stays inactive. */
+const char *malloc_conf = "background_thread:true,dirty_decay_ms:4000";
+#endif
+
size_t (*MEM_allocN_len)(const void *vmemh) = MEM_lockfree_allocN_len;
void (*MEM_freeN)(void *vmemh) = MEM_lockfree_freeN;
void *(*MEM_dupallocN)(const void *vmemh) = MEM_lockfree_dupallocN;