21 #ifndef __UT_MemoryCounter__ 
   22 #define __UT_MemoryCounter__ 
   30 #define UT_MEMORY_DEBUG_LOGGING 0 
   31 #if !defined(UT_MEMORY_DEBUG_LOGGING) || UT_MEMORY_DEBUG_LOGGING==0 
   32 #define UT_MEMORY_DEBUG_LOG(m,s) 
   33 #define UT_MEMORY_DEBUG_LOG_SHARED(m,s,p,r) 
   35 #define UT_MEMORY_DEBUG_LOG(m,s)            {printf(m ": %" SYS_PRId64 " B\n", s); fflush(stdout);} 
   36 #define UT_MEMORY_DEBUG_LOG_SHARED(m,s,p,r) {printf(m ": %" SYS_PRId64 " B, 0x%p, refcount=%" SYS_PRId64 "\n", s,p,r); fflush(stdout);} 
   49         , myMustCountShared(true)
 
   50         , myMustCountUnshared(true)
 
   86         myUnsharedCount += 
size;
 
   94         myUnsharedCount += 
size;
 
  102         return myUnsharedCount;
 
  113         return myMustCountShared;
 
  125         return myMustCountUnshared;
 
  131         , myMustCountShared(countshared)
 
  132         , myMustCountUnshared(countunshared)
 
  137     size_t myUnsharedCount;
 
  143     const bool myMustCountShared;
 
  150     const bool myMustCountUnshared;
 
  185         , myFullSharedCount(0)
 
  186         , myUniqueSharedCount(0)
 
  195         myVisitedCount.
clear();
 
  196         myFullSharedCount = 0;
 
  197         myUniqueSharedCount = 0;
 
  210             UT_ASSERT_MSG_P(myVisitedCount.
count(p) == 0, 
"Why is p with refcount==1 referred to here more than once?");
 
  215         else if (myVisitedCount.
count(p) == 0)
 
  217             myVisitedCount[p] = 1;
 
  218             myFullSharedCount += 
size;
 
  222             exint newvisitcount = ++myVisitedCount[p];
 
  225             if (newvisitcount == refcount)
 
  226                 myUniqueSharedCount += 
size;
 
  227             UT_ASSERT_MSG_P(newvisitcount <= refcount, 
"Why is p referred to here more times than its refcount?");
 
  245     size_t myFullSharedCount;
 
  246     size_t myUniqueSharedCount;
 
  257         , myFullSharedCount(0)
 
  266         myVisitedSet.
clear();
 
  267         myFullSharedCount = 0;
 
  280             UT_ASSERT_MSG_P(myVisitedSet.
count(p) == 0, 
"Why is p with refcount==1 referred to here more than once?");
 
  285         else if (myVisitedSet.
count(p) == 0)
 
  288             myFullSharedCount += 
size;
 
  302     size_t myFullSharedCount;
 
  333         mySharedCount += 
fpreal(size)/refcount;
 
  361         , myAvoidSet(avoidset)
 
  362         , myNewSharedCount(0)
 
  363         , myFullSharedCount(0)
 
  373         myNewSharedCount = 0;
 
  374         myFullSharedCount = 0;
 
  385         myFullSharedCount += 
size;
 
  386         if (myAvoidSet.
count(p) == 0)
 
  388             myNewSharedCount += 
size;
 
  390                 myUniqueCount += 
size;
 
  394             UT_ASSERT_MSG_P(refcount > 1, 
"If we're the only one referring to this block, why is it in myAvoidSet?");
 
  417     size_t myNewSharedCount;
 
  418     size_t myUniqueCount;
 
  419     size_t myFullSharedCount;
 
  434         , myAvoidSet(avoidset)
 
  436         , myNewSharedCount(0)
 
  437         , myFullSharedCount(0)
 
  438         , myUniqueSharedCount(0)
 
  447         myVisitedCount.
clear();
 
  448         myNewSharedCount = 0;
 
  449         myFullSharedCount = 0;
 
  450         myUniqueSharedCount = 0;
 
  464             UT_ASSERT_MSG_P(myVisitedCount.
count(p) == 0, 
"Why is p with refcount==1 referred to here more than once?");
 
  465             UT_ASSERT_MSG_P(myAvoidSet.
count(p) == 0, 
"Why is p with refcount==1 referred to here and in the input set?");
 
  470         else if (myVisitedCount.
count(p) == 0)
 
  472             myVisitedCount[p] = 1;
 
  473             myFullSharedCount += 
size;
 
  474             if (myAvoidSet.
count(p) == 0)
 
  475                 myNewSharedCount += size;
 
  479             exint newvisitcount = ++myVisitedCount[p];
 
  482             if (newvisitcount == refcount)
 
  484                 UT_ASSERT_MSG_P(myAvoidSet.
count(p) == 0, 
"Why does p have all refcount references here and also appear in the input set?");
 
  485                 myUniqueSharedCount += 
size;
 
  487             UT_ASSERT_MSG_P(newvisitcount <= refcount, 
"Why is p referred to here more times than its refcount?");
 
  512     size_t myNewSharedCount;
 
  513     size_t myUniqueSharedCount;
 
  514     size_t myFullSharedCount;
 
  527         , myGatherSet(gatherset)
 
bool countShared(size_t size, exint refcount, const void *p) override
 
size_t getFullCount() const 
 
~UT_MemoryCounterTotal() override
 
std::pair< iterator, bool > insert(const value_type &value)
 
bool countShared(size_t size, exint refcount, const void *p) override
 
bool countShared(size_t size, exint refcount, const void *p) override
 
~UT_MemoryCounterGather() override
 
bool countShared(size_t size, exint refcount, const void *p) override
 
~UT_MemoryCounterNewSafe() override
 
bool countShared(size_t size, exint refcount, const void *p) override
 
virtual bool countShared(size_t size, exint refcount, const void *p)
 
#define UT_ASSERT_MSG_P(ZZ,...)
 
#define UT_IF_ASSERT_P(ZZ)
 
UT_MemoryCounterFullSafe()
 
UT_MemoryCounterNew(const UT::ArraySet< const void * > &avoidset)
 
size_t getFullCount() const 
 
bool countShared(size_t size, exint refcount, const void *p) override
 
size_t getCount() const override
This returns the current count of memory used. 
 
UT_MemoryCounter(const bool countshared, const bool countunshared)
 
size_t getUniqueCount() const 
 
~UT_MemoryCounterUniqueFullSafe() override
 
size_t getFullCount() const 
 
size_t getUniqueCount() const 
 
bool countShared(size_t size, exint refcount, const void *p) override
 
bool mustCountUnshared() const 
 
~UT_MemoryCounterUnique() override
 
UT_MemoryCounterGather(UT::ArraySet< const void * > &gatherset)
 
size_t getCount() const override
This returns the current count of memory used. 
 
virtual size_t getCount() const 
 
fpreal32 SYSrint(fpreal32 val)
 
~UT_MemoryCounterFullSafe() override
 
void countUnshared(size_t size)
 
virtual ~UT_MemoryCounter()
 
size_type count(const Key &key) const 
 
UT_MemoryCounterUniqueFullSafe()
 
size_t getCount() const override
This returns the current count of "new" memory used. 
 
size_type count(const Key &key) const 
 
size_t getUniqueCount() const 
 
~UT_MemoryCounterNew() override
 
bool mustCountShared() const 
 
UT_MemoryCounterNewSafe(const UT::ArraySet< const void * > &avoidset)
 
size_t getFullCount() const