Add method to use allocator app defaults.
Currently, apps turn off zeroing of memory and enable the decay
timer. For shell commands, set these values when the environment
variable MALLOC_USE_APP_DEFAULTS is set. This fixes performance
differences found between shell spawned command-line tools and
native code running in an app.
Add a unit test to verify setting after exec.
Bug: 302212507
Test: Set the variable to 1 and verified the decay time is enabled.
Test: Set the variable to "" and also unset it and verified the decay
Test: time is not enabled.
Test: Verified that with the variable set, the memory is not zero'd
Test: by default.
Test: Unit tests pass.
Change-Id: I22a47f70f1ce1205c16195532c54b2bf9403e9cd
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index cd96375..85e742c 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -185,6 +185,7 @@
/*load_bias = */ 0);
__libc_init_mte_stack(/*stack_top = */ raw_args);
__libc_init_scudo();
+ __libc_globals.mutate(__libc_init_malloc);
__libc_init_profiling_handlers();
__libc_init_fork_handler();