diff --git a/image_analysis/scale_merge/RotationScaleMerge.cpp b/image_analysis/scale_merge/RotationScaleMerge.cpp index be65e5678..5312363a9 100644 --- a/image_analysis/scale_merge/RotationScaleMerge.cpp +++ b/image_analysis/scale_merge/RotationScaleMerge.cpp @@ -6476,7 +6476,13 @@ RotationScaleMerge::Result RotationScaleMerge::RunArm(bool scale_partials, bool // resize, not assign: the gather below writes every field of every full, so zeroing 80 bytes // each first is a few hundred megabytes of pure write traffic per chain. The staging arrays are - // members for the same reason. + // members for the same reason. Nothing in them survives the gather either, so when they have + // to grow they are freed first: growing in place would copy the previous chain's records into + // the new allocation only for the gather to overwrite them. + if (static_cast(nf) > fulls.capacity()) { + fulls = {}; + fulls_staging = {}; + } fulls.resize(nf); FullsStaging &st = fulls_staging; st.Resize(nf);