R
Robert A Riedel
I am having a difficult time solving a memory leak in a DLL. The problem
occurs because I cannot find a way to control the termination of threads
managed by the DLL.
In a thread procedure that is part of the DLL data segment there is an
allocation that occurs from the heap. This heap allocation is leaked when a
process using the DLL exits because the DLL CRT startup and termination code
calls ExitProcess(), which terminates all threads.
The DLL code itself does not start the thread. Code in the client process
starts threads by calling a DLL function.
Is there any way to get notification of the process exit before the CRT
calls ExitProcess? I tried atexit(), but this also appears to execute after
the CRT ExitProcess call.
Or perhaps the thread procedure needs to be in the EXE data segment instead
of the DLL data segment?
--
======================================================================
======================================================================
==
== Bob Riedel
== Beckman Coulter, Incorporated
== PO Box 8000 W-529
== 200 S Kraemer Blvd
== Brea CA 92822-8000
==
== Email 1: (e-mail address removed)
== Email 2: (e-mail address removed)
==
==
== The opinions expressed are my own, and do not necessarily represent
== those of Beckman Coulter, Inc.
==
======================================================================
======================================================================
==
== "Effective education is the key to successful democracy."
==
== "Criticizing the actions of others offers so little risk, and
== requires so little effort that it is, without exception, the tool
== of the lazy and of the foolish -- who have neither the intelligence
== to discover, nor the discipline to pursue, a realistic
== alternative."
==
======================================================================
======================================================================
occurs because I cannot find a way to control the termination of threads
managed by the DLL.
In a thread procedure that is part of the DLL data segment there is an
allocation that occurs from the heap. This heap allocation is leaked when a
process using the DLL exits because the DLL CRT startup and termination code
calls ExitProcess(), which terminates all threads.
The DLL code itself does not start the thread. Code in the client process
starts threads by calling a DLL function.
Is there any way to get notification of the process exit before the CRT
calls ExitProcess? I tried atexit(), but this also appears to execute after
the CRT ExitProcess call.
Or perhaps the thread procedure needs to be in the EXE data segment instead
of the DLL data segment?
--
======================================================================
======================================================================
==
== Bob Riedel
== Beckman Coulter, Incorporated
== PO Box 8000 W-529
== 200 S Kraemer Blvd
== Brea CA 92822-8000
==
== Email 1: (e-mail address removed)
== Email 2: (e-mail address removed)
==
==
== The opinions expressed are my own, and do not necessarily represent
== those of Beckman Coulter, Inc.
==
======================================================================
======================================================================
==
== "Effective education is the key to successful democracy."
==
== "Criticizing the actions of others offers so little risk, and
== requires so little effort that it is, without exception, the tool
== of the lazy and of the foolish -- who have neither the intelligence
== to discover, nor the discipline to pursue, a realistic
== alternative."
==
======================================================================
======================================================================