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

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: Address reviewers' comments 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
Index: base/memory/discardable_memory.h
diff --git a/base/memory/discardable_memory.h b/base/memory/discardable_memory.h
index c6a8d82da72363d3dc2cecbb01547eeb64c226eb..0cae99f5494d1ad1cd7a8d3600982ee772dc0771 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
@@ -44,6 +47,8 @@ enum LockDiscardableMemoryStatus {
// - Mac: http://trac.webkit.org/browser/trunk/Source/WebCore/platform/mac/PurgeableBufferMac.cpp
// the comment starting with "vm_object_purgable_control" at
// http://www.opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/vm/vm_object.c
+//
+// Thread-safety: DiscardableMemory instances are not thread-safe.
class BASE_EXPORT DiscardableMemory {
public:
virtual ~DiscardableMemory() {}
@@ -53,6 +58,10 @@ class BASE_EXPORT DiscardableMemory {
static scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size);
+ // Returns the memory's actual size that is greater or equal than the
+ // size requested at construction.
+ virtual size_t Size() const = 0;
+
// 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

Powered by Google App Engine
This is Rietveld 408576698