-
Notifications
You must be signed in to change notification settings - Fork 40
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
Out of memory error with simple fix #147
Comments
What is likely happening is you are allocating either Mats or other native data structures during pipeline execution, rather then only before loop execution. The GC doesn't know how to properly handle these native resources, and gets confused. Anything allocated during the loop, if it has a |
I do clone a mat which I was deliberately not releasing. My concern was that I didn't know if the mat I was creating would still be in use when I released it (due to an imageSource.putFrame(output) call). I have tried releasing it and it seems to work, but my, limited, understanding is that in general one can't be sure that a mat is no longer in use when passed off to some black box routine in the opencv world. |
putFrame does explicitly make an internal copy so it is safe to free the mat after that. Same with something like imshow. The functions that display usually make a copy internally specifically for this reason. |
I noticed that after running for a while (much more than an FRC match) my pipeline code would eventually crash due to an Out of Memory error. I corrected this by adding a System.gc() line to the endless loop at the bottom of Main. As expected the free memory on the webpage drops every second for 10 seconds and then cycles back to the original number and starts dropping again. All good after an overnight run.
The text was updated successfully, but these errors were encountered: