Commit d467a6a9 authored by Gabriel Marin's avatar Gabriel Marin Committed by Commit Bot

tcmalloc: Add generic.total_physical_bytes property to MallocExtension

Original CL:

- https://codereview.chromium.org/1410353005

  Add generic.total_physical_bytes property to MallocExtension

  The actual physical memory usage of tcmalloc cannot be obtained by
  GetNumericProperty. This accounts for the current_allocated_bytes,
  fragmentation and malloc metadata, and excludes the unmapped memory
  regions. This helps the user to understand how much memory is actually
  being used for the allocations that were made.

  This change is done only in chromium tree since the
  metadata_unmapped_bytes is added only in the chromium's tcmalloc in
  CL: www.crrev.com/10499004.

  This is to be used by malloc dump provider for tracing.

  BUG=546491
  Committed: https://crrev.com/0752ec9c6adf641985db1a3a224bf9b8e32e4ac8
  Cr-Commit-Position: refs/heads/master@{#357155}

BUG=724399,b:70905156

Change-Id: I68ae586aacf2f2c1ab09721716b9093d402d649c
Reviewed-on: https://chromium-review.googlesource.com/1130803Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Commit-Queue: Gabriel Marin <gmx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596287}
parent a977d165
...@@ -164,6 +164,14 @@ class PERFTOOLS_DLL_DECL MallocExtension { ...@@ -164,6 +164,14 @@ class PERFTOOLS_DLL_DECL MallocExtension {
// freed memory regions // freed memory regions
// This property is not writable. // This property is not writable.
// //
// "generic.total_physical_bytes"
// Estimate of total bytes of the physical memory usage by the
// allocator ==
// current_allocated_bytes +
// fragmentation +
// metadata
// This property is not writable.
//
// tcmalloc // tcmalloc
// -------- // --------
// "tcmalloc.max_total_thread_cache_bytes" // "tcmalloc.max_total_thread_cache_bytes"
......
...@@ -723,6 +723,14 @@ class TCMallocImplementation : public MallocExtension { ...@@ -723,6 +723,14 @@ class TCMallocImplementation : public MallocExtension {
return true; return true;
} }
if (strcmp(name, "generic.total_physical_bytes") == 0) {
TCMallocStats stats;
ExtractStats(&stats, NULL, NULL, NULL);
*value = stats.pageheap.system_bytes + stats.metadata_bytes -
stats.pageheap.unmapped_bytes;
return true;
}
if (strcmp(name, "tcmalloc.slack_bytes") == 0) { if (strcmp(name, "tcmalloc.slack_bytes") == 0) {
// Kept for backwards compatibility. Now defined externally as: // Kept for backwards compatibility. Now defined externally as:
// pageheap_free_bytes + pageheap_unmapped_bytes. // pageheap_free_bytes + pageheap_unmapped_bytes.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment