memory calculation