fix calculation of used memory