Browse Source

[csharp] Fixed memory leak in Triangulator

badlogic 8 years ago
parent
commit
5b691065bf
1 changed files with 7 additions and 1 deletions
  1. 7 1
      spine-csharp/src/Triangulator.cs

+ 7 - 1
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);
 				}
 			}