summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Stacul <laurent.stacul@amadeus.com>2018-10-15 16:56:18 +0200
committerAliaksey Kandratsenka <alkondratenko@gmail.com>2019-02-10 11:14:23 -0800
commit5574c87e39ee592c909cb48245c1d91e90ddaf4d (patch)
tree2eedd135e08a08f2a484dece827d111201d33582
parente9ab4c53041ac62feefbbb076d326e9a77dd1567 (diff)
downloadgperftools-5574c87e39ee592c909cb48245c1d91e90ddaf4d.tar.gz
Compile time aggressive decommit option
[alkondratenko@gmail.com: performed s/agressive/aggressive/g] Signed-off-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
-rw-r--r--configure.ac11
-rw-r--r--src/static_vars.cc10
2 files changed, 20 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 22992fc..00b4e7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -667,6 +667,17 @@ AC_ARG_ENABLE([large-alloc-report],
AS_IF([test "x$enable_large_alloc_report" = xyes],
[AC_DEFINE([ENABLE_LARGE_ALLOC_REPORT], 1, [report large allocation])])
+# Enable aggressive decommit by default
+AC_ARG_ENABLE([aggressive-decommit-by-default],
+ [AS_HELP_STRING([--enable-aggressive-decommit-by-default],
+ [enable aggressive decommit by default])],
+ [enable_aggressive_decommit_by_default="$enableval"],
+ [enable_aggressive_decommit_by_default=no])
+AS_IF([test "x$enable_aggressive_decommit_by_default" = xyes],
+ [AC_DEFINE([ENABLE_AGGRESSIVE_DECOMMIT_BY_DEFAULT],
+ 1,
+ [enable aggressive decommit by default])])
+
# Write generated configuration file
AC_CONFIG_FILES([Makefile
src/gperftools/tcmalloc.h src/windows/gperftools/tcmalloc.h])
diff --git a/src/static_vars.cc b/src/static_vars.cc
index 5da3a7b..ab5a9cc 100644
--- a/src/static_vars.cc
+++ b/src/static_vars.cc
@@ -91,9 +91,17 @@ void Static::InitStaticVars() {
new (&pageheap_.memory) PageHeap;
+#if defined(ENABLE_AGGRESSIVE_DECOMMIT_BY_DEFAULT)
+ const bool kDefaultAggressiveDecommit = true;
+#else
+ const bool kDefaultAggressiveDecommit = false;
+#endif
+
+
bool aggressive_decommit =
tcmalloc::commandlineflags::StringToBool(
- TCMallocGetenvSafe("TCMALLOC_AGGRESSIVE_DECOMMIT"), false);
+ TCMallocGetenvSafe("TCMALLOC_AGGRESSIVE_DECOMMIT"),
+ kDefaultAggressiveDecommit);
pageheap()->SetAggressiveDecommit(aggressive_decommit);