diff options
| author | pliard@chromium.org <pliard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-25 18:24:46 +0000 |
|---|---|---|
| committer | pliard@chromium.org <pliard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-25 18:24:46 +0000 |
| commit | 73786be789262f72114030ccba586d898184a1ba (patch) | |
| tree | 0394c9d8d3eb09d49ede314b742120f7ee470f32 /base/memory/discardable_memory_allocator_android.h | |
| parent | ad65a3ee540552ecca50ebbf9382f1a4c718d383 (diff) | |
| download | chromium_src-73786be789262f72114030ccba586d898184a1ba.zip chromium_src-73786be789262f72114030ccba586d898184a1ba.tar.gz chromium_src-73786be789262f72114030ccba586d898184a1ba.tar.bz2 | |
Make size of ashmem regions based on device's physical memory.
Ashmem regions created by the ashmem allocator used to be fixed to 32 MBytes
which can be a little small for high-end devices.
This change makes the allocator create ashmem regions of those sizes:
- 64 MBytes for 512 MBytes devices
- 128 MBytes for 1 GByte devices
- 256 MBytes for 2 GBytes...
This also adds an error code path in case ashmem creation fails which may
happen if the address space is too fragmented. In this case the allocator
repetitively retries by dividing the ashmem region size by 2 until the ashmem
region reaches 32 MBytes (which is the minimum).
TBR=bulach@chromium.org
Review URL: https://codereview.chromium.org/119923002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242497 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/memory/discardable_memory_allocator_android.h')
| -rw-r--r-- | base/memory/discardable_memory_allocator_android.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/base/memory/discardable_memory_allocator_android.h b/base/memory/discardable_memory_allocator_android.h index 7991656..7ced405 100644 --- a/base/memory/discardable_memory_allocator_android.h +++ b/base/memory/discardable_memory_allocator_android.h @@ -32,13 +32,12 @@ namespace internal { // discardable_memory.h for DiscardableMemory's threading guarantees. class BASE_EXPORT_PRIVATE DiscardableMemoryAllocator { public: - // Exposed for testing. - enum { - kMinAshmemRegionSize = 32 * 1024 * 1024, - }; - // Note that |name| is only used for debugging/measurement purposes. - explicit DiscardableMemoryAllocator(const std::string& name); + // |ashmem_region_size| is the size that will be used to create the underlying + // ashmem regions and is expected to be greater or equal than 32 MBytes. + DiscardableMemoryAllocator(const std::string& name, + size_t ashmem_region_size); + ~DiscardableMemoryAllocator(); // Note that the allocator must outlive the returned DiscardableMemory @@ -53,6 +52,7 @@ class BASE_EXPORT_PRIVATE DiscardableMemoryAllocator { base::ThreadChecker thread_checker_; const std::string name_; + const size_t ashmem_region_size_; base::Lock lock_; ScopedVector<AshmemRegion> ashmem_regions_; |
