| 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
|
|
|