[geary/mjog/problem-report-memory-fixes: 1/3] ProblemReport: Clear logs iteratively, not recursively
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/problem-report-memory-fixes: 1/3] ProblemReport: Clear logs iteratively, not recursively
- Date: Sun, 1 Mar 2020 10:57:03 +0000 (UTC)
commit 88f4ade0722977ce30f139635b64826b0146e364
Author: Michael Gratton <mike vee net>
Date: Sun Mar 1 20:41:25 2020 +1100
ProblemReport: Clear logs iteratively, not recursively
Clear logs iteratively to avoid recursively freeing all log messages on
the stack at once.
src/engine/api/geary-problem-report.vala | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
diff --git a/src/engine/api/geary-problem-report.vala b/src/engine/api/geary-problem-report.vala
index 7a4b056d..5f21b856 100644
--- a/src/engine/api/geary-problem-report.vala
+++ b/src/engine/api/geary-problem-report.vala
@@ -30,6 +30,22 @@ public class Geary.ProblemReport : Object {
this.latest_log = Logging.get_latest_record();
}
+ ~ProblemReport() {
+ // Manually clear each log record in a loop if we have the
+ // only reference to it so that finalisation of each is an
+ // iterative process. If we just nulled out the record,
+ // finalising the first would cause second to be finalised,
+ // which would finalise the third, etc., and the recursion
+ // could cause the stack to blow right out for large log
+ // buffers.
+ Logging.Record? earliest = this.earliest_log;
+ this.earliest_log = null;
+ this.latest_log = null;
+ while (earliest != null) {
+ earliest = earliest.next;
+ }
+ }
+
/** Returns a string representation of the report, for debugging only. */
public string to_string() {
return "%s".printf(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]