Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak? #2

Open
literalpie opened this issue May 9, 2020 · 5 comments
Open

Memory leak? #2

literalpie opened this issue May 9, 2020 · 5 comments

Comments

@literalpie
Copy link
Contributor

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:
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:
image

Please let me know if you need more information. I can put some time into trying to create a minimal repro if needed.

@lhuanyu
Copy link
Owner

lhuanyu commented May 10, 2020

Thanks a lot! I forgot releasing linked-list data like TEdge and OutPt after calculations. I will fix it in next commit.

@lhuanyu lhuanyu closed this as completed May 10, 2020
@literalpie
Copy link
Contributor Author

literalpie commented May 12, 2020

@lhuanyu Wow, thank you so much for the quick response and fix!

However, I believe there may still be an issue with OutPts being retained after a difference operation. For example, after running the following code, Xcode shows two OutPts 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)

@lhuanyu
Copy link
Owner

lhuanyu commented May 12, 2020

OK. I will check it later.

@literalpie
Copy link
Contributor Author

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.

@lhuanyu lhuanyu reopened this Jun 12, 2020
@lhuanyu
Copy link
Owner

lhuanyu commented Jun 12, 2020

Sorry, I am very busy with my personal project recently. I have reopened this issue for later checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants