diff options
author | Aliaksey Kandratsenka <alk@tut.by> | 2014-02-22 13:09:05 -0800 |
---|---|---|
committer | Aliaksey Kandratsenka <alk@tut.by> | 2014-02-22 13:09:33 -0800 |
commit | a92fc76f72318f7a46e91d9ef6dd24f2bcf44802 (patch) | |
tree | ca246837fed6f46082c2ee61946c08976369a020 | |
parent | c7ce50cd04ea08bd20d4ea4b2924e6a4451d2565 (diff) | |
download | gperftools-a92fc76f72318f7a46e91d9ef6dd24f2bcf44802.tar.gz |
issue-489: enable chromium-style decommitting on env variable
TCMALLOC_AGGRESSIVE_DECOMMIT=t now enables aggressive decommitting by
default.
-rw-r--r-- | src/static_vars.cc | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/static_vars.cc b/src/static_vars.cc index 1502279..1fa9b40 100644 --- a/src/static_vars.cc +++ b/src/static_vars.cc @@ -67,17 +67,6 @@ void CentralCacheUnlockAll() } #endif -static inline -void SetupAtForkLocksHandler() -{ -#if defined(HAVE_FORK) && defined(HAVE_PTHREAD) - pthread_atfork(CentralCacheLockAll, // parent calls before fork - CentralCacheUnlockAll, // parent calls after fork - CentralCacheUnlockAll); // child calls after fork -#endif -} - - SpinLock Static::pageheap_lock_(SpinLock::LINKER_INITIALIZED); SizeMap Static::sizemap_; CentralFreeListPadded Static::central_cache_[kNumClasses]; @@ -111,6 +100,25 @@ void Static::InitStaticVars() { Sampler::InitStatics(); } + +#if defined(HAVE_FORK) && defined(HAVE_PTHREAD) + +static inline +void SetupAtForkLocksHandler() +{ + pthread_atfork(CentralCacheLockAll, // parent calls before fork + CentralCacheUnlockAll, // parent calls after fork + CentralCacheUnlockAll); // child calls after fork +} REGISTER_MODULE_INITIALIZER(tcmalloc_fork_handler, SetupAtForkLocksHandler()); +#endif + +static +void SetupAggressiveDecommit() +{ + Static::pageheap()->SetAggressiveDecommit(EnvToBool("TCMALLOC_AGGRESSIVE_DECOMMIT", false)); +} +REGISTER_MODULE_INITIALIZER(tcmalloc_setup_aggressive_decommit, SetupAggressiveDecommit()); + } // namespace tcmalloc |