Re: [xml] Memory trouble with libxml.

I place a loop around the main section of the code the memory usage grows
for every loop, which indicates that it is not the parsers static
structures that are leaking.

  Okay, that's useful information that you didn't gave, right ?

Sure, but I didn't try that until you mentioned that i needed to free up
the static parser structures, and that did not solve the problem.

  To know whether xmlCleanupParser() call is needed it means I need
to fully understand your code. In general when using libxml this call
is needed. This may not be the case there, I can't be sure, creating
attribute nodes from string for example may require checking whether
entities are declared, which may call the entity code, which may
initialize the predefined entities which will need xmlCleanupParser() ...
or not!

Now that is usefull information that you did not give in the documentation
right? My point is that it is often hard to convey all necesssary
information, or to understand what the required information might be.
Particularly when working with a new library that is mostly unfamiliar.

  That section also include a detailed way to debug any possible memory
allocation problem. 

I could have told you exactly where the allocations where occuring. This
was not the issue. They all occured when I was creating a child element.
It was also clear to me that the allocations being made where required.
What I didn't understand was how to get them to free prorperly. This was
the heart of my question. I appologize if that was not clear. I should
have made my example smaller so that you could fit it all in your head
easily. My bad. I wrote a whole lot more code than I sent. It was only
when I noticed a memory leek that I traced it to my usage of libxml. I
then pared down what I wrote and sent it off. I should have framed my
question more clearly, and will attempt to do so in the future.

  That is a *reproductible process* that is IMHO understandable, which
allow to pinpoint precisely the errors in memory allocation and chase them.

I knew precisely where they where, but could not figure out why the
xmlFreeDoc was not freeing them properly. The output was correct, so I
mistakenly thought that the structure was properly built. I understand now
that my structure was built, but that it was not hooked into the document

say in the section on reporting bugs that I can't debug other people

I was asking why the document I created wasn't properly being freed. This
is clearly a library usage issue to me, and I could not find the answer in
the documentation or in the examples. Next time I won't include the code, 
I just thought it would be easy for somebody who knew how to use the
library to see my howlingly large error, which upon you scanning the code
you did notice quickly. My feeling is that your initial reaction to seeing
code was not to look at it at all to see if you could see what the problem
was, but rather a knee jerk reaction to seeing code at all. 

I thought that is what these sorts of lists where for, but aparently I was
mistaken. I did not understand how to use the library proplerly, and could
not figure it out after two days of trying. Perhaps my debugging skills
are not as robust as yours, but then perhaps you where not always as
robust as they are now.

You never attached the
node account_node to the document doc, you just passed a reference 
but it's not sufficient, that's the cause of the problem.

Thank you. That does in fact solve my problem, and was the kind of help
that I was looking for in the first place. I did not realize that the only
person on this list who answers questions is you. On most lists that I
have asked for help on before there are many people who are more than
willing to help new adoptors understand how to use the software. I now
know that this is not the case here. My mistake.

 There is an example to build a tree from scratch in

it does:

 doc = xmlNewDoc("1.0");
 doc->children = xmlNewDocNode(doc, NULL, "EXAMPLE", NULL);

I appologize for missing this detail. It was not my intention to waste
your time. I read that section quite a number of days ago, and followed it
at first, but must have changed it at some point to something akin to what
I sent. From the functional reference it was not clear that this was

It seems strange to me to have to set this, when this is not required with
the xmlNew*Child functions. There are some other things about the
interface that I find to be a little strange. For example, why are almost
all functions xml<Verb><Noun> like xmlFreeDoc, and xmlFreeNode, but the
functions that deal with buffers are the other way, i.e. xmlBufferFree?

Anyway, thanks for your time and help, even if you gave it grudgingly. I
won't bug you anymore.


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