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

Unified Diff: third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp

Issue 1676453002: Change initialization strategy of AllocationRegister back (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp
diff --git a/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp b/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp
index b96fdb7ce7abd6ab2f7fa7d1838a65f20caae817..5025908fc1ca84dd7f6aa366b6df08063a82f0b5 100644
--- a/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp
+++ b/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp
@@ -137,8 +137,9 @@ bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l
return true;
}
+// |m_allocationRegister| should be initialized only when necessary to avoid waste of memory.
PartitionAllocMemoryDumpProvider::PartitionAllocMemoryDumpProvider()
- : m_allocationRegister(adoptPtr(new base::trace_event::AllocationRegister()))
+ : m_allocationRegister(nullptr)
, m_isHeapProfilingEnabled(false)
{
}
@@ -150,6 +151,11 @@ PartitionAllocMemoryDumpProvider::~PartitionAllocMemoryDumpProvider()
void PartitionAllocMemoryDumpProvider::onHeapProfilingEnabled(bool enabled)
{
if (enabled) {
+ {
+ MutexLocker locker(m_allocationRegisterMutex);
+ if (!m_allocationRegister)
+ m_allocationRegister = adoptPtr(new base::trace_event::AllocationRegister());
+ }
PartitionAllocHooks::setAllocationHook(reportAllocation);
PartitionAllocHooks::setFreeHook(reportFree);
} else {
@@ -164,13 +170,15 @@ void PartitionAllocMemoryDumpProvider::insert(void* address, size_t size, const
base::trace_event::AllocationContext context = base::trace_event::AllocationContextTracker::GetContextSnapshot();
context.type_name = typeName;
MutexLocker locker(m_allocationRegisterMutex);
haraken 2016/02/05 11:20:59 Nit: It would be heavy to use MutexLocker in inser
Primiano Tucci (use gerrit) 2016/02/05 11:42:08 Note that here we have also to protect against con
- m_allocationRegister->Insert(address, size, context);
+ if (m_allocationRegister)
+ m_allocationRegister->Insert(address, size, context);
}
void PartitionAllocMemoryDumpProvider::remove(void* address)
{
MutexLocker locker(m_allocationRegisterMutex);
- m_allocationRegister->Remove(address);
+ if (m_allocationRegister)
+ m_allocationRegister->Remove(address);
}
} // namespace blink
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698