Fix bugs and memory leaks in yolov8 example#1349
Merged
deadprogram merged 7 commits intohybridgroup:devfrom Jan 4, 2026
Merged
Fix bugs and memory leaks in yolov8 example#1349deadprogram merged 7 commits intohybridgroup:devfrom
deadprogram merged 7 commits intohybridgroup:devfrom
Conversation
…s not being closed
deadprogram
reviewed
Jan 3, 2026
Member
|
Hello @swdee thanks for looking into this. Other than the issue with closing right away that I mentioned above, it does in fact work better. 😄 |
…sistent across desktop backends and results in immediate program exit on some
Member
|
Thank you very much for the corrections/improvements @swdee now squash/merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As reported in #1338 the yolov8 detection example program has a memory leak.
This was confirmed with simple profiling.
The PR fixes the memory leak and some other bugs.
gocv.TransposeND(outs[0], []int{0, 2, 1}, &outs[0])call. When&outs[0]is passed as the destination, you end up overwriting the original Mat inouts[0]with a new allocation and you lose the only handle to the old allocation withoutouts[0].Close()being called.classesvariable was not defined. I initially missed seeing it was in a separate file. To avoid others doing this I have removed it and defined it in the main program.colsto get their position, instead of the fixed/absolute positions 0 to 3. This has resolved buggy detection of objects per frame.After the above fixes, Mat profiling reveals all memory leaks are fixed.