[compiler-rt] [scudo] Do a M_PURGE call before changing release interval on Android (PR #87110)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 29 13:44:04 PDT 2024
https://github.com/ChiaHungDuan created https://github.com/llvm/llvm-project/pull/87110
None
>From 9b856d10597fdebd25d5b47236840c4833ff6599 Mon Sep 17 00:00:00 2001
From: Chia-hung Duan <chiahungduan at google.com>
Date: Fri, 29 Mar 2024 20:43:04 +0000
Subject: [PATCH] [scudo] Do a M_PURGE call before changing release interval on
Android
---
compiler-rt/lib/scudo/standalone/wrappers_c.inc | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/compiler-rt/lib/scudo/standalone/wrappers_c.inc b/compiler-rt/lib/scudo/standalone/wrappers_c.inc
index 56d8ef20156e28..21d5b7add51275 100644
--- a/compiler-rt/lib/scudo/standalone/wrappers_c.inc
+++ b/compiler-rt/lib/scudo/standalone/wrappers_c.inc
@@ -247,6 +247,11 @@ void SCUDO_PREFIX(malloc_postinit)() {
INTERFACE WEAK int SCUDO_PREFIX(mallopt)(int param, int value) {
if (param == M_DECAY_TIME) {
if (SCUDO_ANDROID) {
+ // Before changing the interval, reset the memory usage status by doing a
+ // M_PURGE call so that we can minimize the impact of any unreleased pages
+ // introduced by interval transition.
+ SCUDO_ALLOCATOR.releaseToOS(scudo::ReleaseToOS::Force);
+
if (value == 0) {
// Will set the release values to their minimum values.
value = INT32_MIN;
More information about the llvm-commits
mailing list