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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 2925073002: Move malloc/partition_alloc memory usage functions to base (Closed)
Patch Set: Moved to ProcessMetrics method, etc Created 3 years, 6 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
« no previous file with comments | « base/process/process_metrics_win.cc ('k') | third_party/WebKit/Source/platform/wtf/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 46e340ac54eedeeb71df6af1a352ec5125b78907..fdff6ba64b3cad641d89d375f65d696671fc3cd7 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -1735,42 +1735,6 @@ void RenderThreadImpl::OnProcessPurgeAndSuspend() {
base::TimeDelta::FromMinutes(90));
}
-// TODO(tasak): Replace the following GetMallocUsage() with memory-infra
-// when it is possible to run memory-infra without tracing.
-#if defined(OS_WIN)
-namespace {
-
-static size_t GetMallocUsage() {
- // Iterate through whichever heap the CRT is using.
- HANDLE crt_heap = reinterpret_cast<HANDLE>(_get_heap_handle());
- if (crt_heap == NULL)
- return 0;
- if (!::HeapLock(crt_heap))
- return 0 ;
- size_t malloc_usage = 0;
- PROCESS_HEAP_ENTRY heap_entry;
- heap_entry.lpData = NULL;
- while (::HeapWalk(crt_heap, &heap_entry) != 0) {
- if ((heap_entry.wFlags & PROCESS_HEAP_ENTRY_BUSY) != 0)
- malloc_usage += heap_entry.cbData;
- }
- ::HeapUnlock(crt_heap);
- return malloc_usage;
-}
-
-} // namespace
-#elif defined(OS_MACOSX) || defined(OS_IOS)
-namespace {
-
-static size_t GetMallocUsage() {
- malloc_statistics_t stats = {0};
- malloc_zone_statistics(nullptr, &stats);
- return stats.size_in_use;
-}
-
-} // namespace
-#endif
-
bool RenderThreadImpl::GetRendererMemoryMetrics(
RendererMemoryMetrics* memory_metrics) const {
DCHECK(memory_metrics);
@@ -1789,16 +1753,9 @@ bool RenderThreadImpl::GetRendererMemoryMetrics(
blink_stats.partition_alloc_total_allocated_bytes / 1024;
memory_metrics->blink_gc_kb =
blink_stats.blink_gc_total_allocated_bytes / 1024;
-#if defined(OS_LINUX) || defined(OS_ANDROID)
- struct mallinfo minfo = mallinfo();
-#if defined(USE_TCMALLOC)
- size_t malloc_usage = minfo.uordblks;
-#else
- size_t malloc_usage = minfo.hblkhd + minfo.arena;
-#endif
-#else
- size_t malloc_usage = GetMallocUsage();
-#endif
+ std::unique_ptr<base::ProcessMetrics> metric(
+ base::ProcessMetrics::CreateCurrentProcessMetrics());
+ size_t malloc_usage = metric->GetMallocUsage();
memory_metrics->malloc_mb = malloc_usage / 1024 / 1024;
discardable_memory::ClientDiscardableSharedMemoryManager::Statistics
« no previous file with comments | « base/process/process_metrics_win.cc ('k') | third_party/WebKit/Source/platform/wtf/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698