HDK
|
#include <UT_MemoryCounter.h>
Public Member Functions | |
UT_MemoryCounter () | |
virtual | ~UT_MemoryCounter () |
virtual void | reset () |
virtual bool | countShared (size_t size, exint refcount, const void *p) |
void | countUnshared (size_t size) |
virtual size_t | getCount () const |
bool | mustCountShared () const |
bool | mustCountUnshared () const |
Protected Member Functions | |
UT_MemoryCounter (const bool countshared, const bool countunshared) | |
This is the base class of a set of classes for simplifying counting of shared memory for different use cases. The base class counts all shared memory as if it is unshared, thus computing the total amount of memory used by something, assuming that the same block of memory is never referenced more than once.
Definition at line 44 of file UT_MemoryCounter.h.
|
inline |
Definition at line 47 of file UT_MemoryCounter.h.
|
inlinevirtual |
NOTE: The virtual destructor is needed to destruct subclass members, even if no special destruction is necessary for the subclass itself.
Definition at line 56 of file UT_MemoryCounter.h.
|
inlineprotected |
Definition at line 129 of file UT_MemoryCounter.h.
|
inlinevirtual |
This counts shared memory according to the requirements of the use case. The default implementation counts the total amount of memory referenced by something, assuming the same block is never referenced more than once.
This returns true if the memory counter has recorded this shared memory pointer at least once before. If you have a shared object that itself owns separately shared data, if calling countShared for the outer level of shared data returns true, the inner level of shared data doesn't need to be counted again. For example, when counting the memory of packed primitives, multiple packed primitives may be referencing the same detail, and multiple details may be sharing attribute data, so if the countShared call for the detail handle returns true, the detail doesn't need to be traversed again.
NOTE: Subclasses should NOT call UT_MemoryCounter::countShared().
Reimplemented in UT_MemoryCounterGather, UT_MemoryCounterNewSafe, UT_MemoryCounterNew, UT_MemoryCounterTotal, UT_MemoryCounterFullSafe, UT_MemoryCounterUniqueFullSafe, and UT_MemoryCounterUnique.
Definition at line 83 of file UT_MemoryCounter.h.
|
inline |
This counts unshared memory, which doesn't require any special handling.
Definition at line 92 of file UT_MemoryCounter.h.
|
inlinevirtual |
This returns the current count of memory used. NOTE: Subclasses should call UT_MemoryCounter::getCount() to get the unshared memory contribution.
Reimplemented in UT_MemoryCounterNewSafe, UT_MemoryCounterNew, and UT_MemoryCounterTotal.
Definition at line 100 of file UT_MemoryCounter.h.
|
inline |
If this returns false, the code using the UT_MemoryCounter doesn't need to compute memory usage for a complicated object if its refcount > 1.
NOTE: Subclasses must handle shared memory appropriately, even if this is false, to avoid having to always check this.
Definition at line 111 of file UT_MemoryCounter.h.
|
inline |
If this returns false, the code using the UT_MemoryCounter doesn't need to compute memory usage for a complicated object if it is unshared or has refcount == 1.
NOTE: Subclasses must handle memory with refcount==1 appropriately, even if this is false, to avoid having to always check this.
Definition at line 123 of file UT_MemoryCounter.h.
This resets any data structures used for counting to their freshly-constructed state. NOTE: Subclasses should call UT_MemoryCounter::reset().
Reimplemented in UT_MemoryCounterGather, UT_MemoryCounterNewSafe, UT_MemoryCounterNew, UT_MemoryCounterTotal, UT_MemoryCounterFullSafe, and UT_MemoryCounterUniqueFullSafe.
Definition at line 61 of file UT_MemoryCounter.h.