fixing heap memory calculation