From a92fc76f72318f7a46e91d9ef6dd24f2bcf44802 Mon Sep 17 00:00:00 2001 From: Aliaksey Kandratsenka Date: Sat, 22 Feb 2014 13:09:05 -0800 Subject: issue-489: enable chromium-style decommitting on env variable TCMALLOC_AGGRESSIVE_DECOMMIT=t now enables aggressive decommitting by default. --- src/static_vars.cc | 30 +++++++++++++++++++----------- 1 file 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 -- cgit v1.2.1