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

Side by Side Diff: base/memory/discardable_memory_mac.cc

Issue 17106004: Add discardable memory emulation for non-android/mac platforms (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing review. Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/discardable_memory.h" 5 #include "base/memory/discardable_memory.h"
6 6
7 #include <mach/mach.h> 7 #include <mach/mach.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 namespace base { 11 namespace base {
12 12
13 namespace { 13 namespace {
14 14
15 // The VM subsystem allows tagging of memory and 240-255 is reserved for 15 // The VM subsystem allows tagging of memory and 240-255 is reserved for
16 // application use (see mach/vm_statistics.h). Pick 252 (after chromium's atomic 16 // application use (see mach/vm_statistics.h). Pick 252 (after chromium's atomic
17 // weight of ~52). 17 // weight of ~52).
18 const int kDiscardableMemoryTag = VM_MAKE_TAG(252); 18 const int kDiscardableMemoryTag = VM_MAKE_TAG(252);
19 19
20 } // namespace 20 } // namespace
21 21
22 // static 22 // static
23 bool DiscardableMemory::Supported() { 23 bool DiscardableMemory::SupportedNatively() {
24 return true; 24 return true;
25 } 25 }
26 26
27 DiscardableMemory::~DiscardableMemory() { 27 DiscardableMemory::~DiscardableMemory() {
28 if (memory_) { 28 if (memory_) {
29 vm_deallocate(mach_task_self(), 29 vm_deallocate(mach_task_self(),
30 reinterpret_cast<vm_address_t>(memory_), 30 reinterpret_cast<vm_address_t>(memory_),
31 size_); 31 size_);
32 } 32 }
33 } 33 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return true; 93 return true;
94 } 94 }
95 95
96 // static 96 // static
97 void DiscardableMemory::PurgeForTesting() { 97 void DiscardableMemory::PurgeForTesting() {
98 int state = 0; 98 int state = 0;
99 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state); 99 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state);
100 } 100 }
101 101
102 } // namespace base 102 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698