Split memory management

Some attempts to address #1079 -- just for discussion at this point.
@michaelcahill, did you think about discarding the page immediately at this point, instead of taking a copy of `ref` and handling it later?   It looks to me like the error handling here has gotten messier over time, maybe we should track through it (I'm happy to do that after you merge, if you haven't already done it and decided it's OK.)