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

Unified Diff: base/memory/discardable_memory.h

Issue 25293002: Add DiscardableMemoryAllocator to work around FD limit issue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Shorten critical section + add unit test Created 7 years, 2 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 | « base/base.gypi ('k') | base/memory/discardable_memory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_memory.h
diff --git a/base/memory/discardable_memory.h b/base/memory/discardable_memory.h
index c6a8d82da72363d3dc2cecbb01547eeb64c226eb..e060dd0accc89c4cb6ad0627410dc9f7f0119459 100644
--- a/base/memory/discardable_memory.h
+++ b/base/memory/discardable_memory.h
@@ -30,6 +30,9 @@ enum LockDiscardableMemoryStatus {
// reclaim it if needed. Locks do not nest.
//
// Notes:
+// - If you need more than one instance of DiscardableMemory please use
+// DiscardableMemoryAllocator to avoid using too many file descriptors on
+// platforms where discardable memory is backed by a file.
// - The paging behavior of memory while it is locked is not specified. While
// mobile platforms will not swap it out, it may qualify for swapping
// on desktop platforms. It is not expected that this will matter, as the
@@ -53,6 +56,8 @@ class BASE_EXPORT DiscardableMemory {
static scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size);
+ size_t size() const { return size_; }
+
// Locks the memory so that it will not be purged by the system. Returns
// DISCARDABLE_MEMORY_SUCCESS on success. If the return value is
// DISCARDABLE_MEMORY_FAILED then this object should be discarded and
@@ -78,6 +83,11 @@ class BASE_EXPORT DiscardableMemory {
// Purge all discardable memory in the system. This call has global effects
// across all running processes, so it should only be used for testing!
static void PurgeForTesting();
+
+ protected:
+ DiscardableMemory(size_t size);
+
+ const size_t size_;
};
} // namespace base
« no previous file with comments | « base/base.gypi ('k') | base/memory/discardable_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698