refactor checking history expire heap in memory engine