From bf5a3784790d2819eca304f938f0301613e1becf Mon Sep 17 00:00:00 2001 From: SoftFever Date: Tue, 13 Oct 2026 18:05:51 +0800 Subject: [PATCH] Free G-code result buffers with clear_and_shrink --- src/libslic3r/GCode/GCodeProcessor.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 243aa514cd..9d166805a5 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -2602,16 +2602,13 @@ void GCodeProcessorResult::reset() { //BBS: add mutex for protection of gcode result lock(); - // release rather than clear: these two are sized by the print - one entry per move and one - // per g-code line - and a reset is where the memory is expected to go back to the allocator - // (see BackgroundSlicingProcess::apply()). The capacity would not be reused anyway: the - // result is refilled by move-assigning the processor's own result. - moves = std::vector(); + // moves and lines_ends grow with the print: free them, as no reset result reuses the capacity. + clear_and_shrink(moves); plate_mass = {}; object_masses.clear(); body_masses.clear(); support_masses.clear(); - lines_ends = std::vector(); + clear_and_shrink(lines_ends); printable_area = Pointfs(); //BBS: add bed exclude area bed_exclude_area = Pointfs();