[compiler-rt] r177393 - tsan: instruct malloc() to consume less memory

Dmitry Vyukov dvyukov at google.com
Tue Mar 19 05:24:19 PDT 2013


Author: dvyukov
Date: Tue Mar 19 07:24:19 2013
New Revision: 177393

URL: http://llvm.org/viewvc/llvm-project?rev=177393&view=rev
Log:
tsan: instruct malloc() to consume less memory


Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=177393&r1=177392&r2=177393&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Tue Mar 19 07:24:19 2013
@@ -61,6 +61,7 @@ extern "C" void *__libc_malloc(uptr size
 extern "C" void *__libc_calloc(uptr size, uptr n);
 extern "C" void *__libc_realloc(void *ptr, uptr size);
 extern "C" void __libc_free(void *ptr);
+extern "C" int mallopt(int param, int value);
 const int PTHREAD_MUTEX_RECURSIVE = 1;
 const int PTHREAD_MUTEX_RECURSIVE_NP = 1;
 const int kPthreadAttrSize = 56;
@@ -1831,6 +1832,10 @@ void InitializeInterceptors() {
   REAL(memcpy) = internal_memcpy;
   REAL(memcmp) = internal_memcmp;
 
+  // Instruct libc malloc to consume less memory.
+  mallopt(1, 0);  // M_MXFAST
+  mallopt(-3, 32*1024);  // M_MMAP_THRESHOLD
+
   SANITIZER_COMMON_INTERCEPTORS_INIT;
 
   TSAN_INTERCEPT(longjmp);





More information about the llvm-commits mailing list