| Index: content/common/host_discardable_shared_memory_manager.cc
|
| diff --git a/content/common/host_discardable_shared_memory_manager.cc b/content/common/host_discardable_shared_memory_manager.cc
|
| index c4fea8de54e0c7d3b2e2ab09e8485a2103a39756..834481e2a55c6e6aca4b47843e774981f78110b1 100644
|
| --- a/content/common/host_discardable_shared_memory_manager.cc
|
| +++ b/content/common/host_discardable_shared_memory_manager.cc
|
| @@ -359,12 +359,8 @@ void HostDiscardableSharedMemoryManager::ReduceMemoryUsageUntilWithinLimit(
|
| scoped_refptr<MemorySegment> segment = segments_.back();
|
| segments_.pop_back();
|
|
|
| - // Attempt to purge and truncate LRU segment. When successful, as much
|
| - // memory as possible will be released to the OS. How much memory is
|
| - // released depends on the platform. The child process should perform
|
| - // periodic cleanup to ensure that all memory is release within a
|
| - // reasonable amount of time.
|
| - if (segment->memory()->PurgeAndTruncate(current_time)) {
|
| + // Attempt to purge LRU segment. When successful, released the memory.
|
| + if (segment->memory()->Purge(current_time)) {
|
| ReleaseMemory(segment->memory());
|
| continue;
|
| }
|
| @@ -387,6 +383,11 @@ void HostDiscardableSharedMemoryManager::ReleaseMemory(
|
| DCHECK_GE(bytes_allocated_, size);
|
| bytes_allocated_ -= size;
|
|
|
| + // Shrink memory segment if supported. This will immediately release the
|
| + // memory to the OS.
|
| + if (base::DiscardableSharedMemory::IsShrinkingSupported())
|
| + memory->Shrink();
|
| +
|
| // This will unmap the memory segment and drop our reference. The result
|
| // is that the memory will be released to the OS if the child process is
|
| // no longer referencing it.
|
|
|