Get the size (in bytes) of an object on the heap
I'm aware you can use MemoryLayout .size to get the size of a type T. For example: MemoryLayout .size // 4 However, for class instances (objects), MemoryLayout .size returns the size of the reference to the object (8 bytes on 64 bit machines), not the size of the actual objects on the heap.
Object size on heap
Is there a way to find out how big an object is on the heap? Cheers, - Howard. PS I did search swift-users but no luck Yes, the sizeof() function. -Jens ··· On Mar 19, 2016, at 4:53 PM, Howard Lovatt via swift-users wrote: Is there a way to find out how big an object is on the heap?