Ajeet Pratap Maurya Ajeet Pratap Maurya - 1 year ago 104
Objective-C Question

How to find the size of any object in iOS

I was optimizing my app and wanted to know that how much is the size of the object, so that i can also show it in log.

suppose i have

NSDictionary *temp=(NSDictionary*)[Data objectAtIndex:i];

//data is defined in the .h file

now how will i know that how much is the size of the object temp.

I tried using the variable view and in the temp section i found the
instance_size=(long int)30498656

Is the instance_size is the exact size of my temp object?.

i also tried


but it crashed on that point.
Any help...

Answer Source

The compiler knows only about the pointer, and that is why it will always return size of the pointer. To find the size of the allocated object try something like

NSLog(@"size of Object: %zd", malloc_size(myObject));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download