Re: [xml] Crash/Memory leak in threads.c
- From: "Eugene Gershnik" <gershnik hotmail com>
- To: "Stéphane Bidoul" <stephane bidoul softwareag com>
- Cc: <xml gnome org>, "Igor Zlatkovic" <igor zlatkovic com>
- Subject: Re: [xml] Crash/Memory leak in threads.c
- Date: Sun, 8 Jun 2003 12:16:11 -0700
Stéphane Bidoul wrote:
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?
Right, I mistyped the name.
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.
Sure thing. What I did was to link the CleanupParams structures into a
doubly linked list. The DLL_THREAD_DETACH notification continues to clean up
as before and removes an entry from the list. Finally, on DLL_PROCESS_DETACH
I clean up whatever is left in the linked list. This of course requires a
critical section to protect list insertions/deletions but since it is being
used only on initial xmlGlobalState creation and thread cleanup I don't
think it will have any noticable performance impact.
Best Regards,
Eugene
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]