Save and restore memory allocation state across paths

Helps avoid problems with exhausting address space on long runs.