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

Side by Side Diff: base/trace_event/memory_dump_scheduler.cc

Issue 2775663003: [memory-infra] Fix base_unittests on CFI bots (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "base/trace_event/memory_dump_scheduler.h" 5 #include "base/trace_event/memory_dump_scheduler.h"
6 6
7 #include "base/process/process_metrics.h" 7 #include "base/process/process_metrics.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "base/trace_event/memory_dump_manager.h" 10 #include "base/trace_event/memory_dump_manager.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 275 }
276 276
277 void MemoryDumpScheduler::PollingTriggerState::ResetTotals() { 277 void MemoryDumpScheduler::PollingTriggerState::ResetTotals() {
278 if (!memory_increase_threshold) { 278 if (!memory_increase_threshold) {
279 memory_increase_threshold = kDefaultMemoryIncreaseThreshold; 279 memory_increase_threshold = kDefaultMemoryIncreaseThreshold;
280 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \ 280 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \
281 defined(OS_ANDROID) 281 defined(OS_ANDROID)
282 // Set threshold to 1% of total system memory. 282 // Set threshold to 1% of total system memory.
283 SystemMemoryInfoKB meminfo; 283 SystemMemoryInfoKB meminfo;
284 bool res = GetSystemMemoryInfo(&meminfo); 284 bool res = GetSystemMemoryInfo(&meminfo);
285 if (res) 285 if (res) {
286 memory_increase_threshold = (meminfo.total / 100) * 1024; 286 memory_increase_threshold =
287 (static_cast<int64_t>(meminfo.total) / 100) * 1024;
288 }
289 DCHECK_GT(memory_increase_threshold, 0u);
287 #endif 290 #endif
288 } 291 }
289 292
290 // Update the |last_dump_memory_total|'s value from the totals if it's not 293 // Update the |last_dump_memory_total|'s value from the totals if it's not
291 // first poll. 294 // first poll.
292 if (num_polls_from_last_dump >= 0 && 295 if (num_polls_from_last_dump >= 0 &&
293 last_memory_totals_kb[last_memory_totals_kb_index]) { 296 last_memory_totals_kb[last_memory_totals_kb_index]) {
294 last_dump_memory_total = 297 last_dump_memory_total =
295 last_memory_totals_kb[last_memory_totals_kb_index] * 1024; 298 last_memory_totals_kb[last_memory_totals_kb_index] * 1024;
296 } 299 }
297 num_polls_from_last_dump = 0; 300 num_polls_from_last_dump = 0;
298 for (uint32_t i = 0; i < kMaxNumMemorySamples; ++i) 301 for (uint32_t i = 0; i < kMaxNumMemorySamples; ++i)
299 last_memory_totals_kb[i] = 0; 302 last_memory_totals_kb[i] = 0;
300 last_memory_totals_kb_index = 0; 303 last_memory_totals_kb_index = 0;
301 } 304 }
302 305
303 } // namespace trace_event 306 } // namespace trace_event
304 } // namespace base 307 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698