[xml] Mem leak or not? -- plain text. please reply to this one :)



Here is a message dump from valgrind while closing my app, environment
gnu/linux, and libxml2 is configured with multithreading:
==23789== 5536 bytes in 553 blocks are still reachable in loss record 106 of
111
==23789==    at 0x40169890: malloc (vg_clientfuncs.c:103)
==23789==    by 0x40266013: xmlStrndup (in /usr/lib/libxml2.so.2.5.4)
==23789==    by 0x402660B1: xmlStrdup (in /usr/lib/libxml2.so.2.5.4)
==23789==    by 0x4027AB4F: xmlStaticCopyNode (in /usr/lib/libxml2.so.2.5.4)
...
==23789== 27768 bytes in 534 blocks are still reachable in loss record 108
of 111
==23789==    at 0x40169890: malloc (vg_clientfuncs.c:103)
==23789==    by 0x4027AAD2: xmlStaticCopyNode (in /usr/lib/libxml2.so.2.5.4)
==23789==    by 0x4027ADD0: xmlStaticCopyNodeList (in
/usr/lib/libxml2.so.2.5.4)
==23789==    by 0x4027AE72: xmlCopyNodeList (in /usr/lib/libxml2.so.2.5.4)

"still reachable" means while they were not deallocated, they were
referenced by some pointer. I've called
 xmlFreeDoc(m_xmldoc);
m_xmldoc = NULL;
xmlCleanupParser(); //no children thread using this call right now. for
multithreading see below

Sorry, here is another dumping message:
836 bytes in 19 blocks are still reachable in loss record 92 of 111
==23789==    at 0x40169890: malloc (vg_clientfuncs.c:103)
==23789==    by 0x40278C0E: xmlNewDocProp (in /usr/lib/libxml2.so.2.5.4)
==23789==    by 0x4027A792: xmlCopyProp (in /usr/lib/libxml2.so.2.5.4)
==23789==    by 0x4027A9BC: xmlCopyPropList (in /usr/lib/libxml2.so.2.5.4)


Have to mention that i use xmlCleanupParser() in two places, one is main
thread, and it works fine except above message. After I close the xml parser
in main thread with xmlfree..() and  xmlCleanupParser(), each child thread
may initialize their own xml parsing
environment with  xmlInitParser(),  xmlKeepBlanksDefault(0) and deinitialize
with xmlfree..() and  xmlCleanupParser() as well. The problem is that if I
use  xmlCleanupParser(), I'll get app abort as below:
#0  0x401b3b11 in __kill () from /lib/i686/libc.so.6
#1  0x4002a79b in raise (sig=6) at signals.c:65
#2  0x401b5092 in abort () at ../sysdeps/generic/abort.c:88
#3  0x40208677 in free_check () at malloc.c:4668
#4  0x4020636d in __libc_free (mem=0x8955940) at malloc.c:3122
#5  0x40056f40 in xmlFreeEntity () from /usr/lib/libxml2.so.2
#6  0x4007cf8a in xmlHashFree () from /usr/lib/libxml2.so.2
#7  0x40057ed2 in xmlFreeEntitiesTable () from /usr/lib/libxml2.so.2
#8  0x40057275 in xmlCleanupPredefinedEntities ()
   from /usr/lib/libxml2.so.2
#9  0x400729fc in xmlCleanupParser () from /usr/lib/libxml2.so.2

but if I don't use xmlCleanupParser() in child thread, I'll get another
message from valgrind like this:
==23882== 6144 bytes in 1 blocks are still reachable in loss record 112 of
117
==23882==    at 0x40169890: malloc (vg_clientfuncs.c:103)
==23882==    by 0x40280CAB: xmlHashCreate (in /usr/lib/libxml2.so.2.5.4)
==23882==    by 0x4025BE88: xmlCreateEntitiesTable (in
/usr/lib/libxml2.so.2.5.4)
==23882==    by 0x4025B1B9: xmlInitializePredefinedEntities (in
/usr/lib/libxml2.so.2.5.4)

Thanks




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]