Public Member Functions | List of all members
rapidsmpf::ScopedMemoryRecord Struct Reference

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...
 
ScopedMemoryRecordadd_subscope (ScopedMemoryRecord const &subscope)
 Merge the memory statistics of a subscope into this record. More...
 
ScopedMemoryRecordadd_scope (ScopedMemoryRecord const &scope)
 Merge the memory statistics of another scope into this one. More...
 

Detailed Description

Memory statistics for a specific scope.

Note
Is trivially copyable.

Definition at line 18 of file scoped_memory_record.hpp.

Member Function Documentation

◆ add_scope()

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.

Parameters
scopeThe scope to combine with this one.
Returns
Reference to this object after summing.
See also
add_subscope()

◆ add_subscope()

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.

Parameters
subscopeThe scoped memory record representing a completed nested region.
Returns
Reference to this object after merging the subscope.
See also
add_scope()

◆ current()

std::int64_t rapidsmpf::ScopedMemoryRecord::current ( ) const
noexcept

Returns the current memory usage in bytes.

Current usage is the total bytes currently allocated but not yet deallocated.

Returns
The current memory usage in bytes.

◆ max()

std::int64_t rapidsmpf::ScopedMemoryRecord::max ( ) const
noexcept

Returns the size of the largest single allocation (in bytes).

Returns
The largest single allocation in bytes.

◆ num_current_allocs()

std::int64_t rapidsmpf::ScopedMemoryRecord::num_current_allocs ( ) const
noexcept

Returns the number of currently active (non-deallocated) allocations.

Returns
The number of active allocations.

◆ num_total_allocs()

std::int64_t rapidsmpf::ScopedMemoryRecord::num_total_allocs ( ) const
noexcept

Returns the total number of allocations performed.

Returns
The total number of allocations.

◆ peak()

std::int64_t rapidsmpf::ScopedMemoryRecord::peak ( ) const
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.

Returns
The peak memory usage in bytes.

◆ record_allocation()

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.

Parameters
nbytesThe number of bytes allocated.
Note
Is not thread-safe.

◆ record_deallocation()

void rapidsmpf::ScopedMemoryRecord::record_deallocation ( std::int64_t  nbytes)

Records a memory deallocation event.

Reduces the current memory usage.

Parameters
nbytesThe number of bytes deallocated.
Note
Is not thread-safe.

◆ total()

std::int64_t rapidsmpf::ScopedMemoryRecord::total ( ) const
noexcept

Returns the total number of bytes allocated.

This value accumulates over time and is not reduced by deallocations.

Returns
The total number of bytes allocated.

The documentation for this struct was generated from the following file: