bloomberg / bloomberg/memray

What is total_allocations?

Open
#807 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
15.2k
Forks
461
Avg merge
5d 3h
Merged PRs (30d)
10

Description

What is [total allocations](https://github.com/bloomberg/memray/blob/f2c180db9e9ff32d03b100a7a4ac086c39eb0367/src/memray/_metadata.py#L15)?

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

Contributor guide

Open the contributing guide

Research direction

Start with src/memray/_metadata.py and the JSON report behavior referenced in #620. Trace the meanings of total_num_allocations, total_allocations, total_frames, and peak_memory, then document each on the Memray website, including why the allocation counts differ.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.