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

fix: Fix memory leak issue in screen.capture() [Linux] #12

Merged
merged 1 commit into from
Jul 20, 2022

Conversation

mdacach
Copy link
Contributor

@mdacach mdacach commented Jul 19, 2022

XImage pointer was not being released at the end of the function.

I've found the following function which seems to have solved the issue:
https://tronche.com/gui/x/xlib/utilities/XDestroyImage.html

The following test script was used. It does not keep consuming memory anymore, so I think the issue is solved.
https://gist.github.com/mdacach/3ccc93751af3ee125739b2f994b85e03

P.S. I've found a simple XFree(data as *mut _) to also solve the issue, which I don't fully understand because the image pointer would still leak, I think.

@mdacach
Copy link
Contributor Author

mdacach commented Jul 19, 2022

Related issue

Copy link
Owner

@nashaofu nashaofu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

@nashaofu nashaofu merged commit bf8d951 into nashaofu:master Jul 20, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants