Refactor memory initialization to a common location.