Define LIBXML_THREAD_ALLOC_ENABLED via xmlversion.h Otherwise, direct calls to xmlFree() etc. from the application will use a different set of allocation functions to what was used to allocate the memory internally.