Re: [xml] Crash/Memory leak in threads.c
- From: Stéphane Bidoul <stephane bidoul softwareag com>
- To: Eugene Gershnik <gershnik hotmail com>
- Cc: xml gnome org, Igor Zlatkovic <igor zlatkovic com>, Stéphane Bidoul <stephane bidoul softwareag com>
- Subject: Re: [xml] Crash/Memory leak in threads.c
- Date: Sun, 08 Jun 2003 15:04:29 +0200
Eugene Gershnik wrote:
[...]
1. An application creates some threads _before loading libxml_
2. The application loads libxml explicitly and performs some operations from
the threads created in step 1.
3. The application unloads libxml. At this point the DLL_PROCESS_DETACH
notification _will not be sent_ for the threads that existed prior to libxml
loading (i.e. threads from step 1). Result: memory leak.
I suppose you mean DLL_*THREAD*_DETACH?
DLL_THREAD_DETACH is "sent" when threads terminate normally,
not when dlls are unloaded.
So it looks you're right: a memory leak occurs when libxml is unloaded
explicitly
while some threads that have been using it are still alive.
I belevie that it is impossible to make DLL_PROCESS_DETACH to work
correctly. For myself I solved the problem by storing a list of allocated
xmlGlobalStates and freeing it on DLL_PROCESS_DETACH. I would gladly post
the code if there is an interest in it.
Sure. However, you must continue to free the xmlGlobalState in
DLL_THREAD_DETACH also, for (common) situations where libxml is loaded
and then many threads are created and destroyed.
-sbi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]