SwiftClipper
SwiftClipper copied to clipboard
Memory leak?
First, thank you so much for this library! It is exactly what I needed for a little project I've been working on.
I believe this library is causing a memory leak in my app. I use the "intersection" functionality pretty heavily, and memory usage goes up over time. Analysis with Instruments and other Xcode tools leaks me to think that there is a strong circular reference between OutPt
types, as shown in this image:
I believe I was able to eliminate the leak by making next
and prev
weak
(but I did a lot of messy workarounds to prove that out - I probably broke other functionality in the process).
I believe TEdge has a similar issue:
Please let me know if you need more information. I can put some time into trying to create a minimal repro if needed.
Thanks a lot! I forgot releasing linked-list data like TEdge and OutPt after calculations. I will fix it in next commit.
@lhuanyu Wow, thank you so much for the quick response and fix!
However, I believe there may still be an issue with OutPt
s being retained after a difference
operation. For example, after running the following code, Xcode shows two OutPt
s being retained.
let path2 = [
CGPoint(x: -5, y: 5),
CGPoint(x: 20, y: 5),
CGPoint(x: 20, y: -15),
CGPoint(x: -5, y: -15)
]
let path3 = [
CGPoint(x: 0, y: 5),
CGPoint(x: 25, y: 5),
CGPoint(x: 25, y: -15),
CGPoint(x: 0, y: -15)
]
let differences = path2.difference(path3)
print(differences)
OK. I will check it later.
Hi there, @lhuanyu . I just wanted to check if you've had a chance to look into this issue? I know you may be busy with other things. This is just a friendly reminder since this issue has been closed, I don't want it to be forgotten.
Sorry, I am very busy with my personal project recently. I have reopened this issue for later checking.