openvino
3b56998b - Fix itt resource memory leak issue (#33887)

Commit
108 days ago
Fix itt resource memory leak issue (#33887) ### Details: - The ITT allocate memory from the below call stack. ``` 000001d4`82618d30 00007ffd`12845ff9 vfbasics!AVrfpInitializeCriticalSectionCommon+0x13d 000001d4`82618d38 00007ffc`d277ac4c openvino!__itt_get_collection_state+0x2c [C:\Jenkins\workspace\private-ci\ie\build-windows-vs2022@2\b\repos\openvino\thirdparty\ittapi\ittapi\src\ittnotify\ittnotify_static.c @ 1665] 000001d4`82618d40 00007ffc`d1d68949 openvino!openvino::itt::internal::`dynamic initializer for 'state''+0x9 [src\common\itt\src\itt.cpp @ 22] 000001d4`82618d48 00007ffd`2f8de716 ucrtbase!initterm+0x36 000001d4`82618d50 00007ffc`d2782eea openvino!dllmain_crt_process_attach+0x9a [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp @ 66] 000001d4`82618d58 00007ffc`d2783057 openvino!dllmain_dispatch+0x6f [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp @ 276] 000001d4`82618d60 00007ffd`13d20ec4 verifier!AVrfpStandardDllEntryPointRoutine+0xf4 000001d4`82618d68 00007ffd`20dfb704 vrfcore!VfCoreStandardDllEntryPointRoutine+0x184 000001d4`82618d70 00007ffd`12848694 vfbasics!AVrfpStandardDllEntryPointRoutine+0xf4 000001d4`82618d78 00007ffd`322df86e ntdll!LdrpCallInitRoutineInternal+0x22 000001d4`82618d80 00007ffd`3218bcae ntdll!LdrpCallInitRoutine+0x10e 000001d4`82618d88 00007ffd`321897ac ntdll!LdrpInitializeNode+0x19c 000001d4`82618d90 00007ffd`322176ea ntdll!LdrpInitializeGraphRecurse+0x6a 000001d4`82618d98 00007ffd`32217716 ntdll!LdrpInitializeGraphRecurse+0x96 ``` - Need to call `__itt_release_resources` when unload `openvino.dll`. - The solutions Here is the solution: we create a class used to store all resource deallocation methods, then create a static object. The release method will register to the static object; this object will be released when the dll unload, all release functions will be called in the destructor. In this way, we didn't need to change any code in DLLMain/unload_library. Just use a MACRO to define the function pointer, like the code below. ``` static void shutdown_frontend_resources() { google::protobuf::ShutdownProtobufLibrary(); } OV_REGISTER_SHUTDOWN_CALLBACK(shutdown_frontend_resources) ``` ### Tickets: - [CVS-179009](https://jira.devtools.intel.com/browse/CVS-179009) - [CVS-180657](https://jira.devtools.intel.com/browse/CVS-180657) --------- Co-authored-by: Michal Lukaszewski <michal.lukaszewski@intel.com>
Author
Parents
Loading