Fixed incorrect calculation of memory usage