Re: [xml] Memory leak problem
- From: Lara Blatchford <lara blatchford nteligen com>
- To: Eric Eberhard <flash vicsmba com>, 'BR Chrisman' <brchrisman gmail com>
- Cc: "xml gnome org" <xml gnome org>
- Subject: Re: [xml] Memory leak problem
- Date: Tue, 26 Nov 2019 21:34:10 +0000
Have you considered running your application under a tool like valgrind to see where it reports leaks?
Lara
-----Original Message-----
From: xml <xml-bounces gnome org> On Behalf Of Eric Eberhard
Sent: Tuesday, November 26, 2019 1:47 PM
To: 'BR Chrisman' <brchrisman gmail com>
Cc: xml gnome org
Subject: Re: [xml] Memory leak problem
Thank you for reply. The problem I was solving for is NS not freeing with xmlFreeDoc(node); (which I did
after all my nonsense).
I took out that code and it dies in the same place ... perhaps I should break down and load a new libxml2 as
I would guess that the problem is fixed now. If not, then I am still missing something.
Like I said, I have used it for decades now and never had a problem. A memory leak is only a problem when
... it becomes a problem, otherwise you generally don't notice. This program is making thousands of XML
files that are rather small, it frees the documents between each file. My customer's data has crossed some
line ...
Is there a C call to see how much memory one is consuming? I could likely put that in to try and find it.
Anyone else with ideas please let me know!
Thanks,
Eric
-----Original Message-----
From: xml [mailto:xml-bounces gnome org] On Behalf Of BR Chrisman via xml
Sent: Sunday, November 24, 2019 12:57 PM
Cc: xml gnome org
Subject: Re: [xml] Memory leak problem
On Sat, Nov 23, 2019 at 10:04 AM Eric Eberhard <flash vicsmba com> wrote:
I have used libxml2 since it was libxml so I can’t believe I am having this problem. I’m looking for
someone smarter than me to help out.
I use only the DOM (memory) parser, and an old version at that:
libxml2-2.7.3
I have a program that makes many XML files. They, alone, are not a problem. But when a large amount are
made (100s) it gets a memory error.
After each XML document I make I write them to disk and then free them
(meaning I thought I was freeing ALL the memory). This is not the
case so I assume I am not coding it correctly. This is what I am
doing …
Hi Eric,
I think you should be able to use xmlFreeDoc on the doc object, rather than on any particular node.
One call to that cleans the whole document up.
I have looped this under valgrind before with no issues found.
- Brian Chrisman
The node is passed to this function (xmlNodePtr) named
freeMe(xmlNsPtr node)
Void freeMe(xmlNSPtr node) {
xmlNsPtr next;
xmlNsPtr cur;
cur = node->ns;
while (cur) {
next = cur->next;
if (cur->href) xmlFree((char *) cur->href);
if (cur->prefix) xmlFree((char *) cur->prefix);
cur->href = NULL;
cur->prefix = NULL;
xmlFree((char *)cur);
cur = next;
}
node->ns = NULL;
if (node->type == XML_ELEMENT_NODE ||
node->type == XML_XINCLUDE_START ||
node->type == XML_XINCLUDE_END) {
cur = node->nsDef;
while (cur) {
next = cur->next;
if (cur->href) xmlFree((char *) cur->href);
if (cur->prefix) xmlFree((char *) cur->prefix
cur->href = NULL;
cur->prefix = NULL;
xmlFree((char *)cur);
cur = next;
}
node->nsDef = NULL;
If (node->children)
FreeMe(node->children); //recursive
}
xmlFreeDoc(node);
//done I think freeing up all memory
I LEFT out the tests for NULLS and error checking and other silly things so it would not be too long.
It also repeats mostly the exact same code if the node is NS so I won’t bore you. Don’t use NS much anyway.
Problem is, something is not free()’d up.
So besides the main node and NS is there something else I have to free()? Better, is there a function that
I can pass the node and it free()’s everything for me?
Any help – even sample code – would be much appreciated! Free horse back ride in AZ for a winner?
E
Eric S Eberhard
VICS (Vertical Integrated Computer Systems)
Voice: 928 567 3529
Cell : 928 301 7537 (not reliable except for text or if not home)
2933 W Middle Verde Rd
Camp Verde, AZ 86322
Oh – help me out and please join this group. I need to get large
numbers of members to take to the politicians.
https://www.facebook.com/groups/286143052248115/
This might work to just join?
<table border="0" width="100%" cellspacing="0" cellpadding="0"
style="border-collapse:collapse;"><tr style=""><td height="28"
style="line-height:28px;"> </td></tr><tr><td style=""><table
border="0" width="280" cellspacing="0" cellpadding="0"
style="border-collapse:separate;background-color:#ffffff;border:1px
solid #dddfe2;border-radius:3px;font-family:Helvetica, Arial,
sans-serif;margin:0px auto;"><tr style="padding-bottom: 8px;"><td
style=""><img class="img"
src="https://scontent.fhhr1-1.fna.fbcdn.net/v/t1.0-0/c0.0.584.305a/p32
0x320/50521766_10218655229077782_1167298564032823296_n.jpg?_nc_cat=101
&_nc_ht=scontent.fhhr1-1.fna&oh=d725734d9126b706d402e635740dcd
29&oe=5D00A5A4" width="280" height="146" alt=""
/></td></tr><tr><td style="font-size:14px;font-weight:bold;padding:8px
8px 0px 8px;text-align:center;">Save The Middle Verde</td></tr><tr><td
style="color:#90949c;font-size:12px;font-weight:normal;text-align:cent
er;">Public group · 228 members</td></tr><tr><td style="padding:8px
12px 12px 12px;"><table border="0" cellspacing="0" cellpadding="0"
style="border-collapse:collapse;width:100%;"><tr><td
style="background-color:#4267b2;border-radius:3px;text-align:center;">
<a
style="color:#3b5998;text-decoration:none;cursor:pointer;width:100%;"
href="https://www.facebook.com/plugins/group/join/popup/?group_id=2861
43052248115&source=email_campaign_plugin" target="_blank"
rel="noopener"><table border="0" cellspacing="0" cellpadding="3"
align="center" style="border-collapse:collapse;"><tr><td
style="border-bottom:3px solid #4267b2;border-top:3px solid
#4267b2;color:#FFF;font-family:Helvetica, Arial,
sans-serif;font-size:12px;font-weight:bold;">Join
Group</td></tr></table></a></td></tr></table></td></tr><tr><td
style="border-top:1px solid #dddfe2;font-size:12px;padding:8px
12px;">This group is to help preserve the Middle Verde River, the
Middle Verde Character area as defined in the Town of Camp
Verde's General Plan, the 260
co...</td></tr></table></td></tr><tr style=""><td height="28"
style="line-height:28px;"> </td></tr></table>
_______________________________________________
xml mailing list, project page http://xmlsoft.org/ xml gnome org
https://mail.gnome.org/mailman/listinfo/xml
_______________________________________________
xml mailing list, project page http://xmlsoft.org/ xml gnome org https://mail.gnome.org/mailman/listinfo/xml
_______________________________________________
xml mailing list, project page http://xmlsoft.org/ xml gnome org https://mail.gnome.org/mailman/listinfo/xml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]