Memory statistics for a specific scope. More...
#include <scoped_memory_record.hpp>
Public Member Functions | |
| std::int64_t | num_total_allocs () const noexcept |
| Returns the total number of allocations performed. More... | |
| std::int64_t | num_current_allocs () const noexcept |
| Returns the number of currently active (non-deallocated) allocations. More... | |
| std::int64_t | current () const noexcept |
| Returns the current memory usage in bytes. More... | |
| std::int64_t | total () const noexcept |
| Returns the total number of bytes allocated. More... | |
| std::int64_t | peak () const noexcept |
| Returns the peak memory usage (in bytes). More... | |
| std::int64_t | max () const noexcept |
| Returns the size of the largest single allocation (in bytes). More... | |
| void | record_allocation (std::int64_t nbytes) |
| Records a memory allocation event. More... | |
| void | record_deallocation (std::int64_t nbytes) |
| Records a memory deallocation event. More... | |
| ScopedMemoryRecord & | add_subscope (ScopedMemoryRecord const &subscope) |
| Merge the memory statistics of a subscope into this record. More... | |
| ScopedMemoryRecord & | add_scope (ScopedMemoryRecord const &scope) |
| Merge the memory statistics of another scope into this one. More... | |
Memory statistics for a specific scope.
Definition at line 18 of file scoped_memory_record.hpp.
| ScopedMemoryRecord& rapidsmpf::ScopedMemoryRecord::add_scope | ( | ScopedMemoryRecord const & | scope | ) |
Merge the memory statistics of another scope into this one.
Unlike add_subscope(), this method treats the given scope as a peer or sibling, rather than a nested child. It aggregates totals and allocation counts and updates peak usage by taking the maximum peaks independently.
This is useful for combining memory statistics across multiple independent scopes, such as from different threads or non-nested regions.
| scope | The scope to combine with this one. |
| ScopedMemoryRecord& rapidsmpf::ScopedMemoryRecord::add_subscope | ( | ScopedMemoryRecord const & | subscope | ) |
Merge the memory statistics of a subscope into this record.
Combines the memory tracking data from a nested scope (subscope) into this record, updating statistics to include the subscope's allocations, peaks, and totals.
This method treats the given record as a child scope nested within this scope, so peak usage is updated considering the current usage plus the subscope's peak, reflecting hierarchical (inclusive) memory usage accounting.
This design allows memory scopes to be organized hierarchically, so when querying a parent scope, its statistics are inclusive of all nested scopes — similar to hierarchical memory profiling tools. However, it assumes that the parent scope's statistics remain constant during the execution of the subscope.
| subscope | The scoped memory record representing a completed nested region. |
|
noexcept |
Returns the current memory usage in bytes.
Current usage is the total bytes currently allocated but not yet deallocated.
|
noexcept |
Returns the size of the largest single allocation (in bytes).
|
noexcept |
Returns the number of currently active (non-deallocated) allocations.
|
noexcept |
Returns the total number of allocations performed.
|
noexcept |
Returns the peak memory usage (in bytes).
The peak represents the highest value reached by current memory usage over the lifetime of the scope, including contributions from merged subscopes.
| void rapidsmpf::ScopedMemoryRecord::record_allocation | ( | std::int64_t | nbytes | ) |
Records a memory allocation event.
Updates the allocation counters and memory usage statistics, and adjusts peak usage if the new current usage exceeds the previous peak.
| nbytes | The number of bytes allocated. |
| void rapidsmpf::ScopedMemoryRecord::record_deallocation | ( | std::int64_t | nbytes | ) |
Records a memory deallocation event.
Reduces the current memory usage.
| nbytes | The number of bytes deallocated. |
|
noexcept |
Returns the total number of bytes allocated.
This value accumulates over time and is not reduced by deallocations.