OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "platform/MemoryPurgeController.h" | 6 #include "platform/MemoryPurgeController.h" |
7 | 7 |
8 #include "platform/TraceEvent.h" | 8 #include "platform/TraceEvent.h" |
9 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
10 #include "wtf/Partitions.h" | 10 #include "wtf/Partitions.h" |
(...skipping 27 matching lines...) Expand all Loading... | |
38 } | 38 } |
39 | 39 |
40 void MemoryPurgeController::pageBecameInactive() | 40 void MemoryPurgeController::pageBecameInactive() |
41 { | 41 { |
42 if (!m_inactiveTimer.isActive()) | 42 if (!m_inactiveTimer.isActive()) |
43 m_inactiveTimer.startOneShot(kInactiveTimerIntervalInSecond, BLINK_FROM_ HERE); | 43 m_inactiveTimer.startOneShot(kInactiveTimerIntervalInSecond, BLINK_FROM_ HERE); |
44 } | 44 } |
45 | 45 |
46 void MemoryPurgeController::pageInactiveTask(Timer<MemoryPurgeController>*) | 46 void MemoryPurgeController::pageInactiveTask(Timer<MemoryPurgeController>*) |
47 { | 47 { |
48 static const size_t maxSizeInKB = 10 * 1024; | |
49 | |
50 size_t totalSizeBefore = WTF::Partitions::totalSizeOfCommittedPages(); | |
48 purgeMemory(MemoryPurgeMode::InactiveTab); | 51 purgeMemory(MemoryPurgeMode::InactiveTab); |
52 size_t totalSizeAfter = WTF::Partitions::totalSizeOfCommittedPages(); | |
53 if (totalSizeAfter >= totalSizeBefore) | |
54 return; | |
55 size_t reclaimedInKB = (totalSizeBefore - totalSizeAfter) / 1024; | |
56 if (reclaimedInKB >= maxSizeInKB) | |
57 reclaimedInKB = maxSizeInKB - 1; | |
58 Platform::current()->histogramCustomCounts("MemoryPurgeController.ReclaimedP artitionAllocInactiveTab", reclaimedInKB, 0, maxSizeInKB, 50); | |
rkaplow
2015/11/20 23:13:46
usually should be 1 as the min
bashi
2015/11/24 00:31:10
Done.
| |
49 } | 59 } |
50 | 60 |
51 void MemoryPurgeController::purgeMemory(MemoryPurgeMode purgeMode) | 61 void MemoryPurgeController::purgeMemory(MemoryPurgeMode purgeMode) |
52 { | 62 { |
53 TRACE_EVENT0("blink", "MemoryPurgeController::purgeMemory"); | 63 TRACE_EVENT0("blink", "MemoryPurgeController::purgeMemory"); |
54 for (auto& client : m_clients) | 64 for (auto& client : m_clients) |
55 client->purgeMemory(purgeMode, m_deviceKind); | 65 client->purgeMemory(purgeMode, m_deviceKind); |
56 WTF::Partitions::decommitFreeableMemory(); | 66 WTF::Partitions::decommitFreeableMemory(); |
57 } | 67 } |
58 | 68 |
59 DEFINE_TRACE(MemoryPurgeController) | 69 DEFINE_TRACE(MemoryPurgeController) |
60 { | 70 { |
61 #if ENABLE(OILPAN) | 71 #if ENABLE(OILPAN) |
62 visitor->trace(m_clients); | 72 visitor->trace(m_clients); |
63 #endif | 73 #endif |
64 } | 74 } |
65 | 75 |
66 } // namespace blink | 76 } // namespace blink |
OLD | NEW |