From e9ff4e48f4e6d83a1e3e2293fab4bcb747ea01cf Mon Sep 17 00:00:00 2001 From: buchmann Date: Tue, 11 May 2021 08:31:51 +0200 Subject: [PATCH 1/2] memory leak fixed(?) --- .../OxyPlot.GtkSharp.Shared/GraphicsRenderContext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/OxyPlot.GtkSharp.Shared/GraphicsRenderContext.cs b/Source/OxyPlot.GtkSharp.Shared/GraphicsRenderContext.cs index 0bf4fad..02cb6a0 100644 --- a/Source/OxyPlot.GtkSharp.Shared/GraphicsRenderContext.cs +++ b/Source/OxyPlot.GtkSharp.Shared/GraphicsRenderContext.cs @@ -39,6 +39,11 @@ public class GraphicsRenderContext : RenderContextBase /// private Cairo.Context g; + /// + /// The text layout context + /// + private Pango.Context c; + /// /// Sets the graphics target. /// @@ -47,6 +52,7 @@ public void SetGraphicsTarget(Cairo.Context graphics) { this.g = graphics; this.g.Antialias = Antialias.Subpixel; // TODO .TextRenderingHint = TextRenderingHint.AntiAliasGridFit; + this.c = Pango.CairoHelper.CreateContext(this.g); } /// @@ -258,7 +264,7 @@ public override void DrawText( VerticalAlignment valign, OxySize? maxSize) { - Pango.Layout layout = Pango.CairoHelper.CreateLayout(this.g); + Pango.Layout layout = new Layout(this.c); Pango.FontDescription font = new Pango.FontDescription(); font.Family = fontFamily; font.Weight = (fontWeight >= 700) ? Pango.Weight.Bold : Pango.Weight.Normal; @@ -330,7 +336,7 @@ public override OxySize MeasureText(string text, string fontFamily, double fontS return OxySize.Empty; } this.g.Save(); - Pango.Layout layout = Pango.CairoHelper.CreateLayout(this.g); + Pango.Layout layout = new Layout(this.c); Pango.FontDescription font = new Pango.FontDescription(); font.Family = fontFamily; font.Weight = (fontWeight >= 700) ? Pango.Weight.Bold : Pango.Weight.Normal; From 29002c053eb555fe24f5e359cde391c0a76deb54 Mon Sep 17 00:00:00 2001 From: buchmann Date: Mon, 5 Jul 2021 08:22:58 +0200 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 999cfa8..d1fc024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,3 +9,4 @@ All notable changes to this project will be documented in this file. - Depend on OxyPlot.Core 1.0.0 - Build OxyPlot.GtkSharp with GtkSharp 2.12.45 - Build OxyPlot.GtkSharp3 with GtkSharp 2.99.3 +- Mitigate memory issue with Pango.Layout #11