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 with some functions #104

Open
0rbianta opened this issue Oct 10, 2023 · 2 comments
Open

Memory Leak with some functions #104

0rbianta opened this issue Oct 10, 2023 · 2 comments

Comments

@0rbianta
Copy link

0rbianta commented Oct 10, 2023

While I was looping through frames of VideoCapture I executed this method to show frames on JavaFX image view:
private Image mat2Image(Mat frame) {
MatOfByte buffer = new MatOfByte();
Imgcodecs.imencode(".png", frame, buffer);
return new Image(new ByteArrayInputStream(buffer.toArray()));
}

for some reason it caused memory leak very rapidly like 5mb/s. After that I switch to opencv library from their official website and same code worked fine without any leaks.

@codespearhead
Copy link

codespearhead commented Mar 12, 2024

What do you mean by "After that I switch to opencv library from their official website and same code worked fine"?

If you switched to Python, then there's no guarantee openpnp/opencv is the root of the problem without an MRE.

@0rbianta
Copy link
Author

Everything kept the same after changing opencv library from openpnp to official.
Code given above caused a memory leak. It been a while since I changed the source of that function but it might be an automatic resource management feature in the official library.

As far as I remember, I did expect OpenCV to automatically handle resource management and I didn't free the resources manually. Also I used openpnp with mutli-threading. Was it thread-safe? 🤔

Sorry for not being able to produce a MRE.

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