fix used memory calculation