exyte / Macaw

Powerful and easy-to-use vector graphics Swift library with SVG support
MIT License
6k stars 552 forks source link

Dispose renderer when DrawingView is deinit. #763

Open Moriquendi opened 2 years ago

Moriquendi commented 2 years ago

We saw that a lot of memory is leaked when creating SVGView this way: SVGView(node: try! SVGParser.parse(text: path), frame: CGRect())

I did some debugging and I think I found the issue. DrawingView is not disposing its renderer when it's deinit and so it's leaked. This PR fixes that.

Another way this leaks could be solved (and probably should be to avoid future leaks) is to make animationObservers on a Node a weak array so that it doesn't retain its observers. It's a little bit of extra work but maybe someone will find some time to implement it.

Cheers.