Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Memory Leak on creating threads
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Memory Leak on creating threads

 Post Reply Post Reply
Author
Message
Kudo Shinya View Drop Down
Newbie
Newbie


Joined: 11 November 2024
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kudo Shinya Quote  Post ReplyReply Direct Link To This Post Topic: Memory Leak on creating threads
    Posted: 11 November 2024 at 2:11am
CJ: v22.0.0
VisualStudio: 2022 (17.11.5)
Windows: 11

I am creating numerous worker threads using _beginthreadex and terminating them with _endthreadex(0) and CloseHandle().

When taking a memory snapshot in Visual Studio, a memory leak of 480 bytes per thread occurs at 
MyApp.exe!_AFX_THREAD_STATE.

The call stack is as follows, confirming that the memory was allocated by the Toolkit during thread creation: 
kernel32.dll!0x7ff96021257d() 
MyApp.exe!CXTPSkinManagerDetoursApiHook::ThreadProcHook() - Line 591 
MyApp.exe!AfxGetModuleState() - Line 314 
MyApp.exe!CThreadLocal<_AFX_THREAD_STATE>CreateObject() - Line 200 
MyApp.exe!CThreadLocalObjectGetData() - Line 453 
MyApp.exe!CThreadLocal<_AFX_THREAD_STATE>::GetData() - Line 179 
MyApp.exe!CThreadLocal<_AFX_THREAD_STATE>::operator _AFX_THREAD_STATE *() - Line 191

It seems that using AfxBeginThread instead of _beginthreadex can avoid this issue

My application creates and deletes a very large number of threads, so I cannot overlook this small memory leak. 
Additionally, the libraries my application depends on also seem to create threads, making it impossible to replace all thread creation with AfxBeginThread.

Is there any workaround for this issue?

Regars,
Shinya
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.234 seconds.