Added function to calculate item size in memory