|
Blender V4.3
|
#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) |
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.
| blender::memory_counter::MemoryCounter::MemoryCounter | ( | MemoryCount & | count | ) |
Definition at line 9 of file memory_counter.cc.
| void blender::memory_counter::MemoryCounter::add | ( | const int64_t | bytes | ) |
Add bytes that are uniquely owned, i.e. not shared.
Definition at line 11 of file memory_counter.cc.
References blender::memory_counter::MemoryCount::total_bytes.
Referenced by add_shared(), blender::bke::bake::StringBakeItem::count_memory(), blender::memory_cache::tests::CachedInt::count_memory(), and CustomData_count_memory().
| 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.
| sharing_info | The sharing info that owns the data. If null, the data is assumed to be uniquely owned. |
| count_fn | Function 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().
| 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().