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 "platform/heap/Heap.h" | |
| 8 #include "public/platform/WebMemoryAllocatorDump.h" | |
| 9 #include "public/platform/WebProcessMemoryDump.h" | |
| 10 #include "wtf/Partitions.h" | |
| 11 #include "wtf/Threading.h" | |
| 12 #include "wtf/text/WTFString.h" | |
| 13 | |
| 14 #include <v8.h> | |
| 15 | |
| 16 namespace blink { | |
| 17 | |
| 18 MemoryUsageProvider* MemoryUsageProvider::instance() | |
| 19 { | |
| 20 DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<MemoryUsageProvider>, provide r, new ThreadSpecific<MemoryUsageProvider>); | |
| 21 return provider; | |
| 22 } | |
| 23 | |
| 24 MemoryUsageProvider::MemoryUsageProvider() | |
| 25 : m_isolate(nullptr) | |
| 26 , m_previousSize(0) | |
| 27 { | |
| 28 } | |
| 29 | |
| 30 MemoryUsageProvider::~MemoryUsageProvider() | |
| 31 { | |
| 32 } | |
| 33 | |
| 34 bool MemoryUsageProvider::adjustAmountOfAllocatedMemory() | |
| 35 { | |
| 36 if (!m_isolate) | |
| 37 return false; | |
| 38 | |
| 39 // TODO(peria): Use thread specific heap usage methods, if available. | |
| 40 int64_t currentTotalSize = Heap::allocatedObjectSize() + Heap::markedObjectS ize(); | |
|
haraken
2016/02/08 11:17:20
This is not what we want to report. Heap::allocate
peria
2016/02/09 06:39:59
Done.
| |
| 41 int64_t diff = currentTotalSize - m_previousSize; | |
| 42 m_isolate->AdjustAmountOfExternalAllocatedMemory(diff); | |
| 43 m_previousSize = currentTotalSize; | |
| 44 | |
| 45 return true; | |
| 46 } | |
| 47 | |
| 48 } // namespace blink | |
| OLD | NEW |