-
-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Labels
Description
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp.Drawing
- I have verified if the problem exist in both
DEBUGandRELEASEmode - I have searched open and closed issues to ensure it has not already been reported
Description
DrawTextProcessor leads to memory leaks, well, not actual leaks but undisposed memory buffers.
Actual chain of 'responsibility': DrawTextProcessor -> PolygonScanner -> TessellatedMultipolygon
TessellatedMultipolygon is allocated and used by PolygonScanner here:
ImageSharp.Drawing/src/ImageSharp.Drawing/Shapes/Rasterization/PolygonScanner.cs
Lines 93 to 106 in 241891b
| public static PolygonScanner Create( | |
| IPath polygon, | |
| int minY, | |
| int maxY, | |
| int subsampling, | |
| IntersectionRule intersectionRule, | |
| MemoryAllocator allocator) | |
| { | |
| var multipolygon = TessellatedMultipolygon.Create(polygon, allocator); | |
| var edges = ScanEdgeCollection.Create(multipolygon, allocator, subsampling); | |
| var scanner = new PolygonScanner(edges, multipolygon.TotalVertexCount * 2, minY, maxY, subsampling, intersectionRule, allocator); | |
| scanner.Init(); | |
| return scanner; | |
| } |
It's also allocated here:
ImageSharp.Drawing/src/ImageSharp.Drawing/Shapes/Rasterization/ScanEdgeCollection.cs
Lines 38 to 45 in 241891b
| public static ScanEdgeCollection Create( | |
| IPath polygon, | |
| MemoryAllocator allocator, | |
| int subsampling) | |
| { | |
| TessellatedMultipolygon multipolygon = TessellatedMultipolygon.Create(polygon, allocator); | |
| return Create(multipolygon, allocator, subsampling); | |
| } |
Both cases are used to create ScanEdgeCollection which does not use it after Create method so we hopefully can safely add using statement for both cases and call it a day.
Steps to Reproduce
brianpopow