#807·memray

What is total_allocations?

Author: peekxcCreated Aug 5, 2025Updated Aug 5, 2025

What is total allocations?

For whatever reason, this only shows up in the JSON report (see #620).

Suppose I get an output like this:

{'total_num_allocations': 2844284,
 'total_bytes_allocated': 526180830,
 'allocation_size_histogram': [...],
 'allocator_type_distribution': {'PYMALLOC_MALLOC': 2721820,
  'PYMALLOC_REALLOC': 122350,
  'REALLOC': 86,
  'PYMALLOC_CALLOC': 22,
  'MALLOC': 6},
 'top_allocations_by_size': [...],
 'metadata': {
  'total_allocations': 5686611,
  'total_frames': 46,
  'peak_memory': 4073520,
  'python_allocator': 'pymalloc',
  'has_native_traces': False,
  'trace_python_allocators': True,
  'file_format': 0}}

Notice that total_num_allocations doesn't match total_allocations. It would be nice in memray included somewhere on its website a description of:

  • what total_num_allocations is
  • what total_allocations is
  • what total_frames is
  • what precisely peak_memory is