Revert "change allocated memory instead of max memory"

This reverts commit da7f471f3caf9fe4ade6f44c4fde27804fa3cab2.