I am using Ojb-c, and I want to know the memory size of an object, but I got this,
NSObject *obj = [[[NSObject alloc] init] autorelease];
NSLog(@"malloc size of myObject: %zd", malloc_size(obj));
NSLog(@"size of myObject: %zd", sizeof(obj));
malloc size of myObject: 16
size of myObject: 4
I know the sizeof(obj) is 4, because the pointer size on ios 32 is 4 bytes, what is the difference?
But more than this,
@interface TestObj : NSObject
@property (nonatomic, retain) NSArray *arr;
@property (nonatomic, assign) int count;
@end
@implementation TestObj
@end
TestObj *obj2 = [[[TestObj alloc] init] autorelease];
NSLog(@"malloc size of obj2: %zd", malloc_size(obj2));
NSLog(@"size of obj2: %zd", sizeof(obj2));
malloc size of obj2: 16
size of obj2: 4
how could I know the real size of TestObj ? thanks.