Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: xml memory leak (?)

23 views
Skip to first unread message

dos

unread,
Aug 13, 2008, 9:10:11 AM8/13/08
to
I did some more tries: i took my "real" program and commented out almost everything. The subroutine i included is run 100-200 times and the memory is allocated massively (about 100 MB). It runs the file i sent to your ftp server some days ago.  I´m really stuck  in searching for the problem. I know those XML Elements at the end should be freed, but they tend to cause me errors when uncommented. -----------------------------------------


xml.c:
http://forums.ni.com/ni/attachments/ni/180/37239/1/xml.c

LuisG

unread,
Aug 13, 2008, 3:40:14 PM8/13/08
to
Hi Dominik, I'm attaching your code after I made a few corrections. I've explained each modification with a comment that starts with "MOD:". Let me know if any of them is unclear. Essentially, the problem you were having is that you were freeing some of the elements more than once, and others (mainly the lists, but also an element or two) were not being freed at all. The comments should explain it. I checked the help for CVIXMLCopyElement, both in the function panel, and in the external help, and I didn't find a problem with the number of parameters. The function expects five parameters: CVIXMLCopyElement (CVIXMLElement srcElem, int copyChildElements,                   CVIXMLElement destParent, int index, CVIXMLElement *destElem); What do you see in the help? As far as the beta is concerned, yes it does follow (roughly) an annual cycle, but currently there is an active beta program, so at this time of the year you should receive a reply within a day or two (note the beta announcement that was posted here in the forum just last week). To answer your last question, if you use the beta, you can get a report of which elements were not cleanly removed. An example for how to deallocate the list that you get from CVIXMLFindElements can be found in the function help itself. Look at the help for the last parameter.
 Luis Message Edited by LuisG on 08-13-2008 02:33 PM


xmltest.c:
http://forums.ni.com/ni/attachments/ni/180/37251/1/xmltest.c

dos

unread,
Aug 15, 2008, 6:40:22 AM8/15/08
to
Hi Luis, first of THANKS VERY MUCH. I got it running - finally. **** One of your comments rang a bell: I didn´t realize that i should not have to dispose an xml element which was  part of a list already being removed. I removed that element explicitely which caused the hell of a number of dynamic memory errors which lead me to not free enough elements finally. **** CVIXMLCopyElement
CVIXMLStatus CVIXMLCopyElement (CVIXMLElement element, int copyChildren, CVIXMLElement parentElement);
Thats what the internal help of my version (8.5) returns - and i think we agree - thats kind of wrong).  ****kind of follow up question: i cannot find any example for writing xml files. I feel quiter stupid, but i don´t understand how to add a new element with cvixmlnewelelment, as it refers to a parent element i do not have (i´m using an empty list). Thanks again for your great help!  
0 new messages