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 99db11720c7c9665d133291f2e691d8b848036d2..d2c210e54ed78e08a222296e5f3b7abcd0818f10 100644 |
--- a/content/common/host_discardable_shared_memory_manager.cc |
+++ b/content/common/host_discardable_shared_memory_manager.cc |
@@ -123,6 +123,8 @@ HostDiscardableSharedMemoryManager::AllocateLockedDiscardableMemory( |
scoped_ptr<base::DiscardableSharedMemory> memory( |
new base::DiscardableSharedMemory(handle)); |
CHECK(memory->Map(size)); |
+ // Close file descriptor to avoid running out. |
+ memory->Close(); |
return make_scoped_ptr(new DiscardableMemoryImpl( |
memory.Pass(), |
base::Bind( |
@@ -237,6 +239,11 @@ 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()); |
@@ -365,6 +372,7 @@ void HostDiscardableSharedMemoryManager::ReleaseMemory( |
// Note: We intentionally leave the segment in the |segments| vector to |
// avoid reconstructing the heap. The element will be removed from the heap |
// when its last usage time is older than all other segments. |
+ memory->Unmap(); |
memory->Close(); |
} |