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

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

Issue 1670463002: [Oilpan] Unify memory usage reporters of Oilpan (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
Index: third_party/WebKit/Source/platform/MemoryUsageProvider.cpp
diff --git a/third_party/WebKit/Source/platform/MemoryUsageProvider.cpp b/third_party/WebKit/Source/platform/MemoryUsageProvider.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b737538b1d0ce7829b9d55b995439a9f36e384a2
--- /dev/null
+++ b/third_party/WebKit/Source/platform/MemoryUsageProvider.cpp
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "platform/MemoryUsageProvider.h"
+
+#include "public/platform/WebMemoryAllocatorDump.h"
+#include "public/platform/WebProcessMemoryDump.h"
+#include "wtf/Partitions.h"
+#include "wtf/Threading.h"
+#include "wtf/text/WTFString.h"
+
+#include <v8.h>
+
+namespace blink {
+
+MemoryUsageProvider* MemoryUsageProvider::instance()
+{
+ DEFINE_THREAD_SAFE_STATIC_LOCAL(WTF::ThreadSpecific<MemoryUsageProvider>, provider, new WTF::ThreadSpecific<MemoryUsageProvider>);
+ return provider;
+}
+
+MemoryUsageProvider::MemoryUsageProvider()
+ : m_isolate(nullptr)
+ , m_previousSize(0)
+{
+}
+
+MemoryUsageProvider::~MemoryUsageProvider()
+{
+}
+
+void MemoryUsageProvider::adjustAmountOfAllocatedMemory()
+{
+ if (!m_isolate)
+ return;
+
+ int64_t partitionAllocSize = WTF::Partitions::totalSizeOfCommittedPages();
+ int64_t oilpanHeapSize = Heap::allocatedSpace();
haraken 2016/02/04 12:00:29 Heap::allocatedSpace() is the size of mmapped regi
peria 2016/02/08 08:41:10 Done with Heap methods, as we discussed offline.
+ int64_t currentTotalSize = partitionAllocSize + oilpanHeapSize;
+ int64_t diff = currentTotalSize - m_previousSize;
+ m_isolate->AdjustAmountOfExternalAllocatedMemory(diff);
+ m_previousSize = currentTotalSize;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698