[Bug] Memory leak
System information (version)
- OpenVINO => 2021.4.689
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2019
- Problem classification: Memory leak
- Framework: Pytorch -> ONNX -> IR
Detailed description
Noticed possible memory leak, when OpenVino wrappers destroyed. Leak is about ~2mb. Probably i did something wrong and did not freed alloacated memory manually, but i cant find a place where i made a mistake
Steps to reproduce
I attach zip file with code in it to reproduce. OpenCV and OpenVino needed.
- Press f5 to run the code
- Take a snapshot of heap memory
- Press
spaceto init model and wait for model to init. (You will see network output) - Press
spaceagain to destroy model - Take a snapshot of heap memory (~2 mb leak)

Issue submission checklist
- [x] I report the issue, it's not a question
- [x] I checked the problem with documentation, FAQ, open issues, Stack Overflow, etc and have not found solution
- [x] There is reproducer code and related data files: images, videos, models, etc.
Consider using for loop to ensure that "leaked" memory grows.
Otherwise it is likely some global singletons or other cached stuff.
Hello and thank you for response. If I undersood correctly, you want me to use for loop for loading network and deleting it from memory? Becauce it's the main issue, that memory does not freed correctly after IE classes destruction. Memory does not grow while IE works with frames.
Thats why I want to know Is an Openvino bug or my fault.
If it is my fault where can I look for correct IE classes destruction and correct memory release after IE work done
Memory allocates every time when network loads and initializes, but when network destructs memory does not releases completely. 2 mb are still allocated. When I load network again, all needed memory allocates again, and 2mb are not released after class destruction again. So I think that it is not a global singleton, cause memory allocates every time
Hi @ZakharovDenis
Could you please test on the latest 2021.4.2 release and see if you continue to see the same behavior?
Regards, Jesus
IDK. Maybe I do something wrong and not clear memory properly, but I see same behaviour on latest openvino release. If you are sure that it is not openvino problem, I will check my code again, probably there is a mistake in code.
Thank you for your support!