Blender V4.3
blender::memory_counter::MemoryCounter Class Reference

#include <BLI_memory_counter.hh>

Inherits blender::NonCopyable, and blender::NonMovable.

Public Member Functions

 MemoryCounter (MemoryCount &count)
 
void add (const int64_t bytes)
 
void add_shared (const ImplicitSharingInfo *sharing_info, const FunctionRef< void(MemoryCounter &shared_memory)> count_fn)
 
void add_shared (const ImplicitSharingInfo *sharing_info, const int64_t bytes)
 

Detailed Description

MemoryCounter helps counting the amount of memory used in cases where data is shared and should not be double-counted. To achieve that, it counts bytes that are uniquely owned separately from those that are shared.

Definition at line 41 of file BLI_memory_counter.hh.

Constructor & Destructor Documentation

◆ MemoryCounter()

blender::memory_counter::MemoryCounter::MemoryCounter ( MemoryCount & count)

Definition at line 9 of file memory_counter.cc.

Member Function Documentation

◆ add()

void blender::memory_counter::MemoryCounter::add ( const int64_t bytes)

◆ add_shared() [1/2]

void blender::memory_counter::MemoryCounter::add_shared ( const ImplicitSharingInfo * sharing_info,
const FunctionRef< void(MemoryCounter &shared_memory)> count_fn )

Add (potentially) shared data which should not be counted twice.

Parameters
sharing_infoThe sharing info that owns the data. If null, the data is assumed to be uniquely owned.
count_fnFunction to count the amount of memory used by the shared data. This is only called if the shared memory was not counted before. It's a callback, because sometimes counting the amount of used memory can be a bit more involved.

Referenced by add_shared(), blender::bke::CurvesGeometry::count_memory(), blender::bke::GeometrySet::count_memory(), and CustomData_count_memory().

◆ add_shared() [2/2]

void blender::memory_counter::MemoryCounter::add_shared ( const ImplicitSharingInfo * sharing_info,
const int64_t bytes )

Same as above, but takes in the number of bytes directly instead of callback. This is easier to use in cases where computing the number of bytes is very cheap.

Definition at line 34 of file memory_counter.cc.

References add(), and add_shared().


The documentation for this class was generated from the following files: