Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "platform/MemoryUsageProvider.h" | |
| 6 | |
| 7 #include "public/platform/WebMemoryAllocatorDump.h" | |
| 8 #include "public/platform/WebProcessMemoryDump.h" | |
| 9 #include "wtf/Partitions.h" | |
| 10 #include "wtf/Threading.h" | |
| 11 #include "wtf/text/WTFString.h" | |
| 12 | |
| 13 #include <v8.h> | |
| 14 | |
| 15 namespace blink { | |
| 16 | |
| 17 MemoryUsageProvider* MemoryUsageProvider::instance() | |
| 18 { | |
| 19 DEFINE_THREAD_SAFE_STATIC_LOCAL(WTF::ThreadSpecific<MemoryUsageProvider>, pr ovider, new WTF::ThreadSpecific<MemoryUsageProvider>); | |
| 20 return provider; | |
| 21 } | |
| 22 | |
| 23 MemoryUsageProvider::MemoryUsageProvider() | |
| 24 : m_isolate(nullptr) | |
| 25 , m_previousSize(0) | |
| 26 { | |
| 27 } | |
| 28 | |
| 29 MemoryUsageProvider::~MemoryUsageProvider() | |
| 30 { | |
| 31 } | |
| 32 | |
| 33 void MemoryUsageProvider::adjustAmountOfAllocatedMemory() | |
| 34 { | |
| 35 if (!m_isolate) | |
| 36 return; | |
| 37 | |
| 38 int64_t partitionAllocSize = WTF::Partitions::totalSizeOfCommittedPages(); | |
| 39 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.
| |
| 40 int64_t currentTotalSize = partitionAllocSize + oilpanHeapSize; | |
| 41 int64_t diff = currentTotalSize - m_previousSize; | |
| 42 m_isolate->AdjustAmountOfExternalAllocatedMemory(diff); | |
| 43 m_previousSize = currentTotalSize; | |
| 44 } | |
| 45 | |
| 46 } // namespace blink | |
| OLD | NEW |