Implement mem.snap() to take memory snapshots.