Further optimize handling of peak data cost
We now only update the peak costs once we leave the peak. This
allows us to merge multiple consecutive allocations, which each
lead to an increment in the peak memory consumption. Instead of
updating the peak costs every time, we now only update the peaks
once at the end of the peak patter, just before memory is freed
or the record process has finished.
This brings the processing time back to the original ~1.2s I have
seen initially for my real-world data file.