Added memory statistics - set SOGoDebugLeaks = YES and call [[self class] memoryStatistics]

This commit is contained in:
Ludovic Marcotte
2014-12-22 19:32:17 -05:00
parent 24a934275f
commit 72732879fa
2 changed files with 29 additions and 0 deletions

View File

@@ -40,6 +40,8 @@
- (NSString *) labelForKey: (NSString *) key
inContext: (WOContext *) context;
+ (void) memoryStatistics;
@end
#endif /* NSOBJECT+UTILITIES_H */

View File

@@ -22,6 +22,7 @@
#import <Foundation/NSArray.h>
#import <Foundation/NSBundle.h>
#import <Foundation/NSDebug.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSString.h>
@@ -122,4 +123,30 @@
return label;
}
+ (void) memoryStatistics
{
Class *classList = GSDebugAllocationClassList ();
Class *pointer;
int i, count, total, peak;
NSString *className;
pointer = classList;
i = 0;
printf("Class count total peak\n");
while (pointer[i] != NULL)
{
className = NSStringFromClass (pointer[i]);
count = GSDebugAllocationCount (pointer[i]);
total = GSDebugAllocationTotal (pointer[i]);
peak = GSDebugAllocationPeak (pointer[i]);
printf("%s %d %d %d\n", [className UTF8String], count, total, peak);
i++;
}
NSZoneFree(NSDefaultMallocZone(), classList);
printf("Done!\n");
}
@end