00001
00032 #ifndef LL_MEMTYPE_H
00033 #define LL_MEMTYPE_H
00034
00035
00036
00037
00038 class LLMemType;
00039
00040 extern void* ll_allocate (size_t size);
00041 extern void ll_release (void *p);
00042
00043 #define MEM_TRACK_MEM 0
00044 #define MEM_TRACK_TYPE (1 && MEM_TRACK_MEM)
00045
00046 #if MEM_TRACK_TYPE
00047 #define MEM_DUMP_DATA 1
00048 #define MEM_TYPE_NEW(T) \
00049 static void* operator new(size_t s) { LLMemType mt(T); return ll_allocate(s); } \
00050 static void operator delete(void* p) { ll_release(p); }
00051
00052 #else
00053 #define MEM_TYPE_NEW(T)
00054 #endif // MEM_TRACK_TYPE
00055
00056
00057
00058
00059 class LLMemType
00060 {
00061 public:
00062
00063 enum EMemType
00064 {
00065 MTYPE_INIT,
00066 MTYPE_STARTUP,
00067 MTYPE_MAIN,
00068
00069 MTYPE_IMAGEBASE,
00070 MTYPE_IMAGERAW,
00071 MTYPE_IMAGEFORMATTED,
00072
00073 MTYPE_APPFMTIMAGE,
00074 MTYPE_APPRAWIMAGE,
00075 MTYPE_APPAUXRAWIMAGE,
00076
00077 MTYPE_DRAWABLE,
00078 MTYPE_OBJECT,
00079 MTYPE_VERTEX_DATA,
00080 MTYPE_SPACE_PARTITION,
00081 MTYPE_PIPELINE,
00082 MTYPE_AVATAR,
00083 MTYPE_PARTICLES,
00084 MTYPE_REGIONS,
00085 MTYPE_INVENTORY,
00086 MTYPE_ANIMATION,
00087 MTYPE_NETWORK,
00088 MTYPE_PHYSICS,
00089 MTYPE_INTERESTLIST,
00090
00091 MTYPE_SCRIPT,
00092 MTYPE_SCRIPT_RUN,
00093 MTYPE_SCRIPT_BYTECODE,
00094
00095 MTYPE_IO_PUMP,
00096 MTYPE_IO_TCP,
00097 MTYPE_IO_BUFFER,
00098 MTYPE_IO_HTTP_SERVER,
00099 MTYPE_IO_SD_SERVER,
00100 MTYPE_IO_SD_CLIENT,
00101 MTYPE_IO_URL_REQUEST,
00102
00103 MTYPE_TEMP1,
00104 MTYPE_TEMP2,
00105 MTYPE_TEMP3,
00106 MTYPE_TEMP4,
00107 MTYPE_TEMP5,
00108 MTYPE_TEMP6,
00109 MTYPE_TEMP7,
00110 MTYPE_TEMP8,
00111 MTYPE_TEMP9,
00112
00113 MTYPE_OTHER,
00114
00115 MTYPE_NUM_TYPES
00116 };
00117 enum { MTYPE_MAX_DEPTH = 64 };
00118
00119 public:
00120 LLMemType(EMemType type)
00121 {
00122 #if MEM_TRACK_TYPE
00123 if (type < 0 || type >= MTYPE_NUM_TYPES)
00124 llerrs << "LLMemType error" << llendl;
00125 if (sCurDepth < 0 || sCurDepth >= MTYPE_MAX_DEPTH)
00126 llerrs << "LLMemType error" << llendl;
00127 sType[sCurDepth] = sCurType;
00128 sCurDepth++;
00129 sCurType = type;
00130 #endif
00131 }
00132 ~LLMemType()
00133 {
00134 #if MEM_TRACK_TYPE
00135 sCurDepth--;
00136 sCurType = sType[sCurDepth];
00137 #endif
00138 }
00139
00140 static void reset();
00141 static void printMem();
00142
00143 public:
00144 #if MEM_TRACK_TYPE
00145 static S32 sCurDepth;
00146 static S32 sCurType;
00147 static S32 sType[MTYPE_MAX_DEPTH];
00148 static S32 sMemCount[MTYPE_NUM_TYPES];
00149 static S32 sMaxMemCount[MTYPE_NUM_TYPES];
00150 static S32 sNewCount[MTYPE_NUM_TYPES];
00151 static S32 sOverheadMem;
00152 static const char* sTypeDesc[MTYPE_NUM_TYPES];
00153 #endif
00154 static S32 sTotalMem;
00155 static S32 sMaxTotalMem;
00156 };
00157
00158
00159
00160 #endif
00161