Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3162)

Unified Diff: base/allocator/partition_allocator/page_allocator.cc

Issue 2818623004: Use MADV_FREE_REUSABLE instead of MADV_FREE in partition alloc for macOS. (Closed)
Patch Set: Add comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/partition_allocator/page_allocator.cc
diff --git a/base/allocator/partition_allocator/page_allocator.cc b/base/allocator/partition_allocator/page_allocator.cc
index 606155fce4a3075c753a8634560a4f69c247509c..bb737b3341986d73739a2f5bed84d0c33052b1ce 100644
--- a/base/allocator/partition_allocator/page_allocator.cc
+++ b/base/allocator/partition_allocator/page_allocator.cc
@@ -216,7 +216,14 @@ bool SetSystemPagesAccessible(void* address, size_t length) {
void DecommitSystemPages(void* address, size_t length) {
DCHECK(!(length & kSystemPageOffsetMask));
#if defined(OS_POSIX)
+#if defined(OS_MACOSX)
+ // On macOS, MADV_FREE_REUSABLE has comparable behavior to MADV_FREE, but also
+ // marks the pages with the reusable bit, which allows both Activity Monitor
+ // and memory-infra to correctly track the pages.
+ int ret = madvise(address, length, MADV_FREE_REUSABLE);
+#else
int ret = madvise(address, length, MADV_FREE);
+#endif
if (ret != 0 && errno == EINVAL) {
// MADV_FREE only works on Linux 4.5+ . If request failed,
// retry with older MADV_DONTNEED . Note that MADV_FREE
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698