objective c - what is the different with malloc_size and sizeof -


i using ojb-c, , want know memory size of object, 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 sizeof(obj) 4, because pointer size on ios 32 4 bytes, difference?

but more 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 know real size of testobj ? thanks.

the sizeof object how space requires object stored in memory. malloc_size how space allocated (for example, in memory allocation system fixed-size pools, might allocated different amount depending on how other memory in use).


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -