Fix memory calculation