Added memory usage calculation