From 5b691065bf9253576870816bb70a225c8385efe9 Mon Sep 17 00:00:00 2001 From: badlogic Date: Thu, 4 May 2017 14:18:51 +0200 Subject: [PATCH] [csharp] Fixed memory leak in Triangulator --- spine-csharp/src/Triangulator.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spine-csharp/src/Triangulator.cs b/spine-csharp/src/Triangulator.cs index 0fadcf15a..baf746302 100644 --- a/spine-csharp/src/Triangulator.cs +++ b/spine-csharp/src/Triangulator.cs @@ -169,7 +169,10 @@ namespace Spine { if (polygon.Count > 0) { convexPolygons.Add(polygon); convexPolygonsIndices.Add(polygonIndices); - } + } else { + polygonPool.Free(polygon); + polygonIndicesPool.Free(polygonIndices); + } polygon = polygonPool.Obtain(); polygon.Clear(); polygon.Add(x1); @@ -244,6 +247,9 @@ namespace Spine { if (polygon.Count == 0) { convexPolygons.RemoveAt(i); polygonPool.Free(polygon); + polygonIndices = convexPolygonsIndices.Items[i]; + convexPolygonsIndices.RemoveAt(i); + polygonIndicesPool.Free(polygonIndices); } }