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

Unified Diff: Source/wtf/Partitions.cpp

Issue 1315113006: Add partitionsOutOfMemoryUsingXXX to know Blink memory usage from OOM crash reports (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 5 years, 3 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 | « Source/wtf/Partitions.h ('k') | Source/wtf/wtf.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/Partitions.cpp
diff --git a/Source/wtf/Partitions.cpp b/Source/wtf/Partitions.cpp
index 1e996bc045488a6ebb09f4e6c1c97630cb18f50c..d3d295b784c84d244723b62dc03a2659cb01d92c 100644
--- a/Source/wtf/Partitions.cpp
+++ b/Source/wtf/Partitions.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "wtf/Partitions.h"
+#include "wtf/Alias.h"
#include "wtf/DefaultAllocator.h"
#include "wtf/FastMalloc.h"
#include "wtf/MainThread.h"
@@ -51,6 +52,7 @@ void Partitions::initialize()
spinLockLock(&s_initializationLock);
if (!s_initialized) {
+ partitionAllocGlobalInit(&Partitions::handleOutOfMemory);
m_fastMallocAllocator.init();
m_bufferAllocator.init();
m_nodeAllocator.init();
@@ -122,4 +124,90 @@ void Partitions::dumpMemoryStats(bool isLightDump, PartitionStatsDumper* partiti
partitionDumpStats(layoutPartition(), "layout_partition", isLightDump, partitionStatsDumper);
}
+static NEVER_INLINE void partitionsOutOfMemoryUsing2G()
+{
+ size_t signature = 2UL * 1024 * 1024 * 1024;
+ alias(&signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionsOutOfMemoryUsing1G()
+{
+ size_t signature = 1UL * 1024 * 1024 * 1024;
+ alias(&signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionsOutOfMemoryUsing512M()
+{
+ size_t signature = 512 * 1024 * 1024;
+ alias(&signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionsOutOfMemoryUsing256M()
+{
+ size_t signature = 256 * 1024 * 1024;
+ alias(&signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionsOutOfMemoryUsing128M()
+{
+ size_t signature = 128 * 1024 * 1024;
+ alias(&signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionsOutOfMemoryUsing64M()
+{
+ size_t signature = 64 * 1024 * 1024;
+ alias(&signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionsOutOfMemoryUsing32M()
+{
+ size_t signature = 32 * 1024 * 1024;
+ alias(&signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionsOutOfMemoryUsing16M()
+{
+ size_t signature = 16 * 1024 * 1024;
+ alias(&signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionsOutOfMemoryUsingLessThan16M()
+{
+ size_t signature = 16 * 1024 * 1024 - 1;
+ alias(&signature);
+ IMMEDIATE_CRASH();
+}
+
+void Partitions::handleOutOfMemory()
+{
+ volatile size_t totalUsage = totalSizeOfCommittedPages();
+
+ if (totalUsage >= 2UL * 1024 * 1024 * 1024)
+ partitionsOutOfMemoryUsing2G();
+ if (totalUsage >= 1UL * 1024 * 1024 * 1024)
+ partitionsOutOfMemoryUsing1G();
+ if (totalUsage >= 512 * 1024 * 1024)
+ partitionsOutOfMemoryUsing512M();
+ if (totalUsage >= 256 * 1024 * 1024)
+ partitionsOutOfMemoryUsing256M();
+ if (totalUsage >= 128 * 1024 * 1024)
+ partitionsOutOfMemoryUsing128M();
+ if (totalUsage >= 64 * 1024 * 1024)
+ partitionsOutOfMemoryUsing64M();
+ if (totalUsage >= 32 * 1024 * 1024)
+ partitionsOutOfMemoryUsing32M();
+ if (totalUsage >= 16 * 1024 * 1024)
+ partitionsOutOfMemoryUsing16M();
+ partitionsOutOfMemoryUsingLessThan16M();
+}
+
} // namespace WTF
« no previous file with comments | « Source/wtf/Partitions.h ('k') | Source/wtf/wtf.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698