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

Unified Diff: Source/wtf/PartitionAlloc.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: 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
Index: Source/wtf/PartitionAlloc.cpp
diff --git a/Source/wtf/PartitionAlloc.cpp b/Source/wtf/PartitionAlloc.cpp
index d14559485d97aa50051843fc2c46b32762e0f7f5..e43617ad53b0f9e2260b5c6d29ea74ec740e55f0 100644
--- a/Source/wtf/PartitionAlloc.cpp
+++ b/Source/wtf/PartitionAlloc.cpp
@@ -31,6 +31,9 @@
#include "config.h"
#include "wtf/PartitionAlloc.h"
+#include "wtf/Alias.h"
+#include "wtf/Partitions.h"
+
#include <string.h>
#ifndef NDEBUG
@@ -59,6 +62,7 @@ int PartitionRootBase::gInitializedLock = 0;
bool PartitionRootBase::gInitialized = false;
PartitionPage PartitionRootBase::gSeedPage;
PartitionBucket PartitionRootBase::gPagedBucket;
+size_t (*PartitionRootBase::gMemoryUsageReportFunction)() = nullptr;
static uint16_t partitionBucketNumSystemPages(size_t size)
{
@@ -138,6 +142,11 @@ static void partitionBucketInitBase(PartitionBucket* bucket, PartitionRootBase*
bucket->numSystemPagesPerSlotSpan = partitionBucketNumSystemPages(bucket->slotSize);
}
+void partitionAllocGlobalInit(size_t (*memoryUsageReportFunc)())
+{
+ PartitionRootBase::gMemoryUsageReportFunction = memoryUsageReportFunc;
+}
+
void partitionAllocInit(PartitionRoot* root, size_t numBuckets, size_t maxAllocation)
{
partitionAllocBaseInit(root);
@@ -299,7 +308,70 @@ static NEVER_INLINE void partitionOutOfMemoryWithLotsOfUncommitedPages()
}
#endif
-static NEVER_INLINE void partitionOutOfMemory(const PartitionRootBase* root)
+static NEVER_INLINE void partitionOutOfMemoryUsing2G()
+{
+ const void* signature = (void*)&partitionOutOfMemoryUsing2G;
+ alias(signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionOutOfMemoryUsing1G()
+{
+ const void* signature = (void*)&partitionOutOfMemoryUsing1G;
+ alias(signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionOutOfMemoryUsing512M()
+{
+ const void* signature = (void*)&partitionOutOfMemoryUsing512M;
+ alias(signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionOutOfMemoryUsing256M()
+{
+ const void* signature = (void*)&partitionOutOfMemoryUsing256M;
+ alias(signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionOutOfMemoryUsing128M()
+{
+ const void* signature = (void*)&partitionOutOfMemoryUsing128M;
+ alias(signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionOutOfMemoryUsing64M()
+{
+ const void* signature = (void*)&partitionOutOfMemoryUsing64M;
+ alias(signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionOutOfMemoryUsing32M()
+{
+ const void* signature = (void*)&partitionOutOfMemoryUsing32M;
+ alias(signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionOutOfMemoryUsing16M()
+{
+ const void* signature = (void*)&partitionOutOfMemoryUsing16M;
+ alias(signature);
+ IMMEDIATE_CRASH();
+}
+
+static NEVER_INLINE void partitionOutOfMemoryUsingLessThan16M()
+{
+ const void* signature = (void*)&partitionOutOfMemoryUsingLessThan16M;
+ alias(signature);
+ IMMEDIATE_CRASH();
+}
+
+static void partitionOutOfMemory(const PartitionRootBase* root)
{
#if !CPU(64BIT)
// Check whether this OOM is due to a lot of super pages that are allocated
@@ -308,7 +380,24 @@ static NEVER_INLINE void partitionOutOfMemory(const PartitionRootBase* root)
partitionOutOfMemoryWithLotsOfUncommitedPages();
}
#endif
- IMMEDIATE_CRASH();
+ volatile size_t totalUsage = (*PartitionRootBase::gMemoryUsageReportFunction)();
+ if (totalUsage >= 2UL * 1024 * 1024 * 1024)
+ partitionOutOfMemoryUsing2G();
+ if (totalUsage >= 1UL * 1024 * 1024 * 1024)
+ partitionOutOfMemoryUsing1G();
+ if (totalUsage >= 512 * 1024 * 1024)
+ partitionOutOfMemoryUsing512M();
+ if (totalUsage >= 256 * 1024 * 1024)
+ partitionOutOfMemoryUsing256M();
+ if (totalUsage >= 128 * 1024 * 1024)
+ partitionOutOfMemoryUsing128M();
+ if (totalUsage >= 64 * 1024 * 1024)
+ partitionOutOfMemoryUsing64M();
+ if (totalUsage >= 32 * 1024 * 1024)
+ partitionOutOfMemoryUsing32M();
+ if (totalUsage >= 16 * 1024 * 1024)
+ partitionOutOfMemoryUsing16M();
+ partitionOutOfMemoryUsingLessThan16M();
}
static NEVER_INLINE void partitionExcessiveAllocationSize()

Powered by Google App Engine
This is Rietveld 408576698