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

Unified Diff: chrome/browser/memory/tab_manager_delegate_chromeos.cc

Issue 2843633002: TabManager: Do not overkill when target memory to free is negative. (Closed)
Patch Set: fix test Created 3 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/memory/tab_manager_delegate_chromeos.cc
diff --git a/chrome/browser/memory/tab_manager_delegate_chromeos.cc b/chrome/browser/memory/tab_manager_delegate_chromeos.cc
index 02ecbd66082c001cfadf4838dc00980d03710707..dbc66dc5b1c7890a2c157059468a1368d7953961 100644
--- a/chrome/browser/memory/tab_manager_delegate_chromeos.cc
+++ b/chrome/browser/memory/tab_manager_delegate_chromeos.cc
@@ -588,21 +588,23 @@ void TabManagerDelegate::LowMemoryKillImpl(
GetSortedCandidates(tab_list, arc_processes);
int target_memory_to_free_kb = mem_stat_->TargetMemoryToFreeKB();
- bool killed_candidate = false;
// Kill processes until the estimated amount of freed memory is sufficient to
// bring the system memory back to a normal level.
// The list is sorted by descending importance, so we go through the list
// backwards.
for (auto it = candidates.rbegin(); it != candidates.rend(); ++it) {
- VLOG(3) << "Target memory to free: " << target_memory_to_free_kb << " KB";
+ MEMORY_LOG(ERROR) << "Target memory to free: " << target_memory_to_free_kb
+ << " KB";
+ if (target_memory_to_free_kb <= 0)
+ break;
// Never kill selected tab or Android foreground app, regardless whether
// they're in the active window. Since the user experience would be bad.
ProcessType process_type = it->process_type();
if (process_type == ProcessType::VISIBLE_APP ||
process_type == ProcessType::FOCUSED_APP ||
process_type == ProcessType::FOCUSED_TAB) {
- VLOG(2) << "Skipped killing " << *it;
+ MEMORY_LOG(ERROR) << "Skipped killing " << *it;
continue;
}
if (it->app()) {
@@ -613,7 +615,8 @@ void TabManagerDelegate::LowMemoryKillImpl(
MemoryKillsMonitor::LogLowMemoryKill("APP", estimated_memory_freed_kb);
MEMORY_LOG(ERROR) << "Killed " << *it << ", estimated "
<< estimated_memory_freed_kb << " KB freed";
- killed_candidate = true;
+ } else {
+ MEMORY_LOG(ERROR) << "Failed to kill " << *it;
}
} else {
int64_t tab_id = it->tab()->tab_contents_id;
@@ -627,16 +630,14 @@ void TabManagerDelegate::LowMemoryKillImpl(
MemoryKillsMonitor::LogLowMemoryKill("TAB", estimated_memory_freed_kb);
MEMORY_LOG(ERROR) << "Killed " << *it << ", estimated "
<< estimated_memory_freed_kb << " KB freed";
- killed_candidate = true;
+ } else {
+ MEMORY_LOG(ERROR) << "Failed to kill " << *it;
}
}
- if (target_memory_to_free_kb < 0)
- break;
}
- if (!killed_candidate) {
- MEMORY_LOG(ERROR) << "Low memory: Unable to kill any candidates. "
- << "Attempted to free " << target_memory_to_free_kb
- << " KB";
+ if (target_memory_to_free_kb > 0) {
+ MEMORY_LOG(ERROR)
+ << "Unable to kill enough candidates to meet target_memory_to_free_kb ";
}
}

Powered by Google App Engine
This is Rietveld 408576698