Skip to content

Fix itt resource memory leak issue#33887

Merged
mlukasze merged 28 commits intoopenvinotoolkit:masterfrom
sgbihu:release_itt
Feb 13, 2026
Merged

Fix itt resource memory leak issue#33887
mlukasze merged 28 commits intoopenvinotoolkit:masterfrom
sgbihu:release_itt

Conversation

@sgbihu
Copy link
Contributor

@sgbihu sgbihu commented Jan 30, 2026

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:

@sgbihu sgbihu requested review from a team as code owners January 30, 2026 05:28
@sgbihu sgbihu requested review from mlukasze and removed request for a team January 30, 2026 05:29
@github-actions github-actions bot added category: inference OpenVINO Runtime library - Inference category: Core OpenVINO Core (aka ngraph) category: build OpenVINO cmake script / infra no-match-files labels Jan 30, 2026
@rkazants rkazants requested a review from praasz January 30, 2026 06:35
@sgbihu sgbihu requested a review from a team as a code owner February 2, 2026 10:59
@sgbihu sgbihu requested review from olpipi and rkazants February 2, 2026 11:08
@olpipi
Copy link
Contributor

olpipi commented Feb 5, 2026

Right now I see a potential issue that DECLARE_OV_SHUTDOWN_FUNC(shutdown_itt_resources) from src/common/itt/src/itt.cpp is compiled into static lib. And linker will not take this function to the final shared lib without explicit reference to the function
The issue doesn't appear in openvino.dll because it takes obj files directly. But the issue may appear for other shared libraries which link against openvino:itt.

I'm working on solution of the issue using attribute((weak)

@sgbihu
Copy link
Contributor Author

sgbihu commented Feb 9, 2026

Right now I see a potential issue that DECLARE_OV_SHUTDOWN_FUNC(shutdown_itt_resources) from src/common/itt/src/itt.cpp is compiled into static lib. And linker will not take this function to the final shared lib without explicit reference to the function The issue doesn't appear in openvino.dll because it takes obj files directly. But the issue may appear for other shared libraries which link against openvino:itt.

I'm working on solution of the issue using attribute((weak)

Hi Oleg, I think the current state is ready. And you mentioned the shutdown didn't have been linked to dll, I think it doesn't need. Because I have debugged the program, the initialise process only called __itt_get_collection_state(); 1 time when load openvino.dll, and __itt_get_collection_state() doesn't be called when load openvino_onnx_frontend.dll. That's the reason why openvino_onnx_frontend.dll doesn't link the callback. And I also checked the link configure, the openvino_onnx_frontend.dll already linked openvino_itt.lib and openvino_shutdown.lib. And the openvino::itt::internal::shutdown(); called atopenvino.dll unload stage.

So I think this is enough.

@praasz praasz added this to the 2026.1 milestone Feb 12, 2026
@olpipi olpipi mentioned this pull request Feb 13, 2026
@mlukasze
Copy link
Contributor

@mvafin as you approved port to release branch #34096
I'm porting back your approval to this one - we are starting merge process

@mlukasze mlukasze added this pull request to the merge queue Feb 13, 2026
Merged via the queue into openvinotoolkit:master with commit 3b56998 Feb 13, 2026
233 of 235 checks passed
Naseer-010 pushed a commit to Naseer-010/openvino that referenced this pull request Feb 18, 2026
### 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>
wilson-seok pushed a commit to wilson-seok/openvino that referenced this pull request Feb 19, 2026
### 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>
mvafin pushed a commit to mvafin/openvino that referenced this pull request Feb 20, 2026
### 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: build OpenVINO cmake script / infra category: Core OpenVINO Core (aka ngraph) category: inference OpenVINO Runtime library - Inference no-match-files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants