Chromium Code Reviews| 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 |