Index: Source/wtf/Partitions.cpp |
diff --git a/Source/wtf/Partitions.cpp b/Source/wtf/Partitions.cpp |
index 800632ea4a009c43f26dd95ac4e1a18aab0a100b..c82b375b026b38f3b85c370ee67e3883bcfed560 100644 |
--- a/Source/wtf/Partitions.cpp |
+++ b/Source/wtf/Partitions.cpp |
@@ -33,6 +33,7 @@ |
#include "wtf/DefaultAllocator.h" |
#include "wtf/FastMalloc.h" |
+#include "wtf/MainThread.h" |
namespace WTF { |
@@ -42,17 +43,19 @@ PartitionAllocatorGeneric Partitions::m_fastMallocAllocator; |
PartitionAllocatorGeneric Partitions::m_bufferAllocator; |
SizeSpecificPartitionAllocator<3328> Partitions::m_objectModelAllocator; |
SizeSpecificPartitionAllocator<1024> Partitions::m_renderingAllocator; |
+HistogramEnumerationFunction Partitions::m_histogramEnumeration = nullptr; |
-void Partitions::initialize() |
+void Partitions::initialize(HistogramEnumerationFunction histogramEnumeration) |
{ |
static int lock = 0; |
// Guard against two threads hitting here in parallel. |
spinLockLock(&lock); |
if (!s_initialized) { |
- m_fastMallocAllocator.init(); |
- m_bufferAllocator.init(); |
- m_objectModelAllocator.init(); |
- m_renderingAllocator.init(); |
+ m_fastMallocAllocator.init(Partitions::notifyCommittedMemoryChanged); |
+ m_bufferAllocator.init(Partitions::notifyCommittedMemoryChanged); |
+ m_objectModelAllocator.init(Partitions::notifyCommittedMemoryChanged); |
+ m_renderingAllocator.init(Partitions::notifyCommittedMemoryChanged); |
+ m_histogramEnumeration = histogramEnumeration; |
s_initialized = true; |
} |
spinLockUnlock(&lock); |
@@ -69,4 +72,26 @@ void Partitions::shutdown() |
(void) m_fastMallocAllocator.shutdown(); |
} |
+void Partitions::notifyCommittedMemoryChanged() |
+{ |
+ static size_t supportedMaxSizeInMB = 4 * 1024; |
+ static size_t observedMaxSizeInMB = 0; |
+ |
+ if (!m_histogramEnumeration) |
+ return; |
+ // We only report the memory in the main thread. |
+ if (!isMainThread()) |
+ return; |
+ // +1 is for rounding up the sizeInMB. |
+ size_t sizeInMB = Partitions::totalSizeOfCommittedPages() / 1024 / 1024 + 1; |
+ if (sizeInMB >= supportedMaxSizeInMB) |
+ sizeInMB = supportedMaxSizeInMB - 1; |
+ if (sizeInMB > observedMaxSizeInMB) { |
+ // Send a UseCounter only when we see the highest memory usage |
+ // we've ever seen. |
+ m_histogramEnumeration("PartitionAlloc.CommittedSize", sizeInMB, supportedMaxSizeInMB); |
Chris Evans
2015/04/06 04:39:53
Hmm! Can we be sure that this histogram enumeratio
haraken
2015/04/06 06:14:14
It can potentially be re-entered, but is it really
|
+ observedMaxSizeInMB = sizeInMB; |
+ } |
+} |
+ |
} // namespace WTF |