How to calculate the size of an object