-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Two codepaths for OpenCL kernel are missing images.clear() #19134
Description
Two codepaths for OpenCL kernel are missing images.clear(). I noticed this during code review tracing memory cleanup.
The two missing paths are the synchronous codepaths. The async codepath has the clear() via a callback.
System information (version)
- OpenCV => 4.5.0
- Operating System / Platform => Windows 10 x64
- Compiler => Visual Studio Community 2019 v16.8.3
Detailed description
In Kernel::Impl::run() the sync codepath has
opencv/modules/core/src/ocl.cpp
Lines 3757 to 3761 in d5fd2f0
| *timeNS = -1; | |
| } | |
| } | |
| cleanupUMats(); | |
| } |
In Kernel::runTask() the sync codepath has
opencv/modules/core/src/ocl.cpp
Lines 3782 to 3786 in d5fd2f0
| if (sync || retval != CL_SUCCESS) | |
| { | |
| CV_OCL_DBG_CHECK(clFinish(qq)); | |
| p->cleanupUMats(); | |
| } |
Compare those to the async codepaths in those same functions. They both setup a callback like..
opencv/modules/core/src/ocl.cpp
Line 3791 in d5fd2f0
| CV_OCL_CHECK(clSetEventCallback(asyncEvent, CL_COMPLETE, oclCleanupCallback, p)); |
and that callback within itself calls finit(e) which is...
opencv/modules/core/src/ocl.cpp
Lines 3364 to 3371 in d5fd2f0
| void finit(cl_event e) | |
| { | |
| CV_UNUSED(e); | |
| cleanupUMats(); | |
| images.clear(); | |
| isInProgress = false; | |
| release(); | |
| } |
The images.clear() is missing from the two sync codepaths. I think it should be added. 🤔 Yes?
Steps to reproduce
- Code review above
Fix
Add the two missing images.clear() calls in the two sync codepaths
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues,
answers.opencv.org, Stack Overflow, etc and have not found solution - I updated to latest OpenCV version and the issue is still there
- There is reproducer code and related data files: videos, images, onnx, etc