Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xmlCleanupParser() memory loss?

Tags:

c

libxml2

as xmlCleanupParser() from the very good libxml2 is not thread-safe, my question is (and I have no possibility to check it out), how much Memory (rough number) is lost to xmlParseFile() and -more importantly- is this memory loss cumulating over many calls to xPF()?

like image 913
Peter Miehle Avatar asked Sep 01 '26 17:09

Peter Miehle


1 Answers

Despite the fact, that malloc() and free() or whatever memory handling implementations are not necessarily thread safe in C < 11, there's always the problem of shared/global memory. File handles to the same file in different threads aren't that bad as long as they're read only.

However, starting with libxml2 2.4.7, you might be able to enable thread safety at the API level, for single threads per document: http://www.xmlsoft.org/threads.html

When I look at the sources of libxml2 2.9.1, I'm positive that thread safety is fully implemented, despite global mutexes, there's also an atomic allocation function.

Downloads: ftp://xmlsoft.org/libxml2/

like image 170
Sam Avatar answered Sep 04 '26 09:09

Sam