Re: [xml] Memory not going away..

(I mistakenly did not reply to mail list, sorry for duplicate.)

I re-compiled with --mem-debug and this is the contents of .memdump:

      11:47:59 AM

      MEMORY ALLOCATED : 0, MAX was 222911016

That's it.  Also, I wrote a quick test to verify what I thought to be
true.. that is that Linux reports the memory correctly as you alloc/free.
I tested both calloc and malloc and top, ps and /proc were all correct.

I think that have some not configured properly since memdump is empty.

Also, does it sounds correct that the parser requires 10 times the XML
file size in memory?  That is just something I noticed.

Thanks for your help and quick response!

David Bauer

Ph.D Candidate, Rensselaer Polytechnic Institute
Computer Science Department

Office: Amos Eaton 205
Phone : (518) 276 2657
URI   :

On Tue, 8 Mar 2005, Daniel Veillard wrote:

On Tue, Mar 08, 2005 at 03:35:30AM -0500, David W. Bauer Jr. wrote:
I have a simple test script I am using to my code:

main(int argc, char **argv, char **env)
        xmlDocPtr       document_network = NULL;
        xmlXPathContextPtr ctxt = NULL;


   you should initialize the library instead, not just XPath

        xmlSetDocCompressMode(document_network, 9);
        document_network = xmlParseFile("network.xml");
        ctxt = xmlXPathNewContext(document_network);


   what do you have in .memdump ?

        return 0;

If I run this in gdb and break on the return statement, then view the
memory usage in top, ps or /proc, I notice that the memory usage does not
go away.

I am using a 300GB file, and the parser is requiring about 3GB if
RAM.  Sorry if this is a simple oversight on my part, but I could not find
the solution in the code examples or online archive.

   depends how the memory allocator works, ps or to report the amount used
by the process not by the library. Try to malloc 3GB of ram in small chunks,
fill them with data, then free() them, without even using libxml2. My bet
is that you will see the same result.
   What the library really allocates or free should be listed in your
.memdump assuming you compiled the library with memory debug


Daniel Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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