HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_MemoryTable.h File Reference
#include "UT_API.h"
#include <SYS/SYS_Types.h>
#include <SYS/SYS_Math.h>
#include <SYS/SYS_AtomicInt.h>
#include "UT_NonCopyable.h"
#include "UT_ThreadSpecificValue.h"
#include <cstddef>
+ Include dependency graph for UT_MemoryTable.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  UT_MemoryUser
 
class  UT_MemoryTable
 
class  UT_MemoryAPI
 

Macros

#define UT_MEMORY_SUBCLASS(STATIC, prefix, table)
 
#define UT_MEMPRINTSIZE   32
 

Functions

UT_API void UTprintMemory (char buf[UT_MEMPRINTSIZE], int64 memory, int field_width=-1)
 

Macro Definition Documentation

#define UT_MEMORY_SUBCLASS (   STATIC,
  prefix,
  table 
)
Value:
STATIC void *prefix##Malloc(int i, size_t amount) \
{ return UT_MemoryAPI::Malloc(table, i, amount); } \
STATIC void *prefix##Calloc(int i, size_t amount) \
{ return UT_MemoryAPI::Calloc(table, i, amount); } \
STATIC void *prefix##Realloc(int i, void *m, size_t o, size_t n) \
{ return UT_MemoryAPI::Realloc(table, i, m, o, n); } \
STATIC void prefix##Free(int i, void *m, size_t amount) \
{ UT_MemoryAPI::Free(table, i, m, amount); } \
STATIC void prefix##acquire(int i, size_t amount) \
{ UT_MemoryAPI::acquire(table, i, amount); } \
STATIC void prefix##release(int i, size_t amount) \
{ UT_MemoryAPI::release(table, i, amount); } \
static inline UT_MemoryTable &prefix##getTable() { return table; }
static void Free(UT_MemoryTable &table, int which_entry, void *memory, size_t amount)
static void * Malloc(UT_MemoryTable &table, int which_entry, size_t amount)
static void * Calloc(UT_MemoryTable &table, int which_entry, size_t amount)
static void * Realloc(UT_MemoryTable &table, int which_entry, void *original_memory, size_t old_amount, size_t new_amount)
GLdouble n
Definition: glcorearb.h:2008
static void acquire(UT_MemoryTable &table, int which_entry, size_t amount)
Track a memory acquisition that wasn't performed by this class.
GLenum GLenum GLsizei void * table
Definition: glad.h:5129
static void release(UT_MemoryTable &table, int which_entry, size_t amount)
Track a memory free that wasn't performed by this class.

When implementing in a different library, the following macro can be used to implement a localized interface. For example, we might have UT_MEMORY_SUBCLASS(, GU, theGUMemoryTable) or class GU_Memory { public: UT_MEMORY_SUBCLASS(static, GU, myMemoryTable) private: static UT_MemoryTable myMemoryTable; };

Definition at line 303 of file UT_MemoryTable.h.

#define UT_MEMPRINTSIZE   32

Convenience function to print memory in a consistent format (i.e. 12.3 KB). To print "18446744073709551616.00 MB" requires 27 characters. There are 5 extra characters for good measure in UT_MEMPRINTSIZE

Definition at line 321 of file UT_MemoryTable.h.

Function Documentation

UT_API void UTprintMemory ( char  buf[UT_MEMPRINTSIZE],
int64  memory,
int  field_width = -1 
)