fixed memory usage calculation