On Sat, Nov 23, 2019 at 10:04 AM Eric Eberhard <fl...@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/p320x320/50521766_10218655229077782_1167298564032823296_n.jpg?_nc_cat=101&_nc_ht=scontent.fhhr1-1.fna&oh=d725734d9126b706d402e635740dcd29&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:center;">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=286143052248115&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