* CheckInstanceCount methods should be made
*/
#ifdef SK_ENABLE_INST_COUNT
+#include <stdlib.h>
#include "SkTArray.h"
extern bool gPrintInstCount;
+// The non-root classes just register themselves with their parent
#define SK_DECLARE_INST_COUNT(className) \
SK_DECLARE_INST_COUNT_INTERNAL(className, \
INHERITED::AddInstChild(CheckInstanceCount);)
+// The root classes registers a function to print out the memory stats when
+// the app ends
#define SK_DECLARE_INST_COUNT_ROOT(className) \
- SK_DECLARE_INST_COUNT_INTERNAL(className, ;)
+ SK_DECLARE_INST_COUNT_INTERNAL(className, atexit(exitPrint);)
#define SK_DECLARE_INST_COUNT_INTERNAL(className, initStep) \
class SkInstanceCountHelper { \
return SkInstanceCountHelper::gInstanceCount; \
} \
\
+ static void exitPrint() { \
+ CheckInstanceCount(); \
+ } \
+ \
static int CheckInstanceCount(int level = 0) { \
if (gPrintInstCount && 0 != SkInstanceCountHelper::gInstanceCount) {\
SkDebugf("%*c Leaked %s: %d\n", \