Add memory recording for benchmarks.