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

Side by Side Diff: third_party/WebKit/Source/platform/MemoryPurgeController.cpp

Issue 1460603002: Add MemoryPurgeController.ReclaimedPartitionAllocInactiveTab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698