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 90eee02594c38a9629b84a443c3ed0076ba2c9e2..e371c8c8795ad22aa2ce93754de6c98e04e2ebe5 100644 |
--- a/content/common/host_discardable_shared_memory_manager.cc |
+++ b/content/common/host_discardable_shared_memory_manager.cc |
@@ -325,6 +325,9 @@ void HostDiscardableSharedMemoryManager::AllocateLockedDiscardableSharedMemory( |
return; |
} |
+ // Close file descriptor to avoid running out. |
+ memory->Close(); |
+ |
base::CheckedNumeric<size_t> checked_bytes_allocated = bytes_allocated_; |
checked_bytes_allocated += memory->mapped_size(); |
if (!checked_bytes_allocated.IsValid()) { |
@@ -335,11 +338,6 @@ void HostDiscardableSharedMemoryManager::AllocateLockedDiscardableSharedMemory( |
bytes_allocated_ = checked_bytes_allocated.ValueOrDie(); |
BytesAllocatedChanged(bytes_allocated_); |
-#if !defined(DISCARDABLE_SHARED_MEMORY_SHRINKING) |
- // Close file descriptor to avoid running out. |
- memory->Close(); |
-#endif |
- |
scoped_refptr<MemorySegment> segment(new MemorySegment(memory.Pass())); |
process_segments[id] = segment.get(); |
segments_.push_back(segment.get()); |
@@ -431,15 +429,6 @@ void HostDiscardableSharedMemoryManager::ReduceMemoryUsageUntilWithinLimit( |
// Attempt to purge LRU segment. When successful, released the memory. |
if (segment->memory()->Purge(current_time)) { |
-#if defined(DISCARDABLE_SHARED_MEMORY_SHRINKING) |
- size_t size = segment->memory()->mapped_size(); |
- DCHECK_GE(bytes_allocated_, size); |
- bytes_allocated_ -= size; |
- // Shrink memory segment. This will immediately release the memory to |
- // the OS. |
- segment->memory()->Shrink(); |
- DCHECK_EQ(segment->memory()->mapped_size(), 0u); |
-#endif |
ReleaseMemory(segment->memory()); |
continue; |
} |