diff options
-rw-r--r-- | src/common.cc | 3 | ||||
-rw-r--r-- | src/thread_cache.cc | 8 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/common.cc b/src/common.cc index 8269fb3..3b66afe 100644 --- a/src/common.cc +++ b/src/common.cc @@ -36,6 +36,7 @@ #include "common.h" #include "system-alloc.h" #include "base/spinlock.h" +#include "getenv_safe.h" // TCMallocGetenvSafe namespace tcmalloc { @@ -51,7 +52,7 @@ static const int32 kDefaultTransferNumObjecs = 32768; static inline void InitTCMallocTransferNumObjects() { if (UNLIKELY(FLAGS_tcmalloc_transfer_num_objects == 0)) { - const char *envval = getenv("TCMALLOC_TRANSFER_NUM_OBJ"); + const char *envval = TCMallocGetenvSafe("TCMALLOC_TRANSFER_NUM_OBJ"); FLAGS_tcmalloc_transfer_num_objects = !envval ? kDefaultTransferNumObjecs : strtol(envval, NULL, 10); } diff --git a/src/thread_cache.cc b/src/thread_cache.cc index eabff40..b98fbee 100644 --- a/src/thread_cache.cc +++ b/src/thread_cache.cc @@ -38,6 +38,7 @@ #include <algorithm> // for max, min #include "base/commandlineflags.h" // for SpinLockHolder #include "base/spinlock.h" // for SpinLockHolder +#include "getenv_safe.h" // for TCMallocGetenvSafe #include "central_freelist.h" // for CentralFreeListPadded #include "maybe_threads.h" @@ -313,9 +314,10 @@ int ThreadCache::GetSamplePeriod() { void ThreadCache::InitModule() { SpinLockHolder h(Static::pageheap_lock()); if (!phinited) { - set_overall_thread_cache_size( - EnvToInt64("TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES", - kDefaultOverallThreadCacheSize)); + const char *tcb = TCMallocGetenvSafe("TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES"); + if (tcb) { + set_overall_thread_cache_size(strtoll(tcb, NULL, 10)); + } Static::InitStaticVars(); threadcache_allocator.Init(); phinited = 1; |