From 9e05c167e9138a802b8f063b4ff029686b1eb1b3 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Sun, 5 Jan 2020 17:35:46 +0100 Subject: [PATCH] Add a malloc_trim() call when deallocating the parser in mh_xslt. Seems to help with memory fragmentation, reason a bit mysterious --- src/internfile/mh_xslt.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/internfile/mh_xslt.cpp b/src/internfile/mh_xslt.cpp index c319731d..867a5ac9 100644 --- a/src/internfile/mh_xslt.cpp +++ b/src/internfile/mh_xslt.cpp @@ -16,6 +16,8 @@ */ #include "autoconfig.h" +#include + #include #include #include @@ -45,6 +47,12 @@ public: virtual ~FileScanXML() { if (ctxt) { xmlFreeParserCtxt(ctxt); + // This should not be necessary (done by free), but see + // http://xmlsoft.org/xmlmem.html#Compacting The + // malloc_trim() and mallopt() doc seems to be a bit + // misleading, there is probably a frag size under which + // free() does not try to malloc_trim() at all + malloc_trim(0); } }