From c5517c0ead25b52f845f8cf5d99444a2398cd252 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Sat, 5 Aug 2023 16:51:34 -0700 Subject: [PATCH] libsysprof: try to break cycles at end of recording --- src/libsysprof/sysprof-recording.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libsysprof/sysprof-recording.c b/src/libsysprof/sysprof-recording.c index a57ace2c..163085ff 100644 --- a/src/libsysprof/sysprof-recording.c +++ b/src/libsysprof/sysprof-recording.c @@ -324,6 +324,12 @@ stop_recording: /* Clear buffers and ensure the disk layer has access to them */ sysprof_capture_writer_flush (self->writer); + /* Aggressively release our instruments so if they have references back + * to the recording any reference cycles are broken. + */ + if (self->instruments->len > 0) + g_ptr_array_remove_range (self->instruments, 0, self->instruments->len); + /* Ignore error types we use to bail out of loops */ if (error != NULL && !g_error_matches (error, DEX_ERROR, DEX_ERROR_TIMED_OUT) &&