Added memory size calculation