|
-
July 18th, 2005, 06:40 AM
#1
Memory leak in loadxml?
Hi, i'm trying to load an xml document from C++ with:
MSXML::IXMLDOMDocumentPtr pXMLDocument (__uuidof (MSXML:OMDocument)); // main document parsed
hr = pXMLDocument->loadXML (BSTRTemp); /* trying parse string, if success, we have doc object*/
this method uses offensive memory. i have xml files that are about 100MB size.
i feel the function does not clear the memory. anyone an idea?
if i load 3 times the same file, my memory is full.
suggestion? is there a free method or something?
thank you,
lutz
-
July 18th, 2005, 07:06 AM
#2
Re: Memory leak in loadxml?
 Originally Posted by LaxRoth
Hi, i'm trying to load an xml document from C++ with:
MSXML::IXMLDOMDocumentPtr pXMLDocument (__uuidof (MSXML:OMDocument)); // main document parsed
hr = pXMLDocument->loadXML (BSTRTemp); /* trying parse string, if success, we have doc object*/
this method uses offensive memory. i have xml files that are about 100MB size.
i feel the function does not clear the memory. anyone an idea?
if i load 3 times the same file, my memory is full.
suggestion? is there a free method or something?
thank you,
lutz

at starting Initializes the COM library with CoInitialize(NULL)
after finishing your xml work
Closes the COM library
by CoUnInitialize()
Deallocates a string allocated Memory
use ::SysFreeString(BSTR);
check for CString that if your allocated memory all are free or not
then check whether you are allocating memory with new or not if yes
Don't forget to Release it use delete []
if still proble let me know
//to release BSTR memory
-
July 18th, 2005, 07:17 AM
#3
Re: Memory leak in loadxml?
Hi, all done. sorry, not written explicitly.
currently:
hr = pXMLDocument->load (filename); /* trying parse string, if success, we have doc object*/
i iterate over a function that creates smartptr this way:
MSXML::IXMLDOMDocumentPtr pXMLDocument (__uuidof (MSXML: OMDocument));
looks like this:
CoInitialize(NULL);
--> Iterate 200x
--> MSXML::IXMLDOMDocumentPtr pXMLDocument
---> pXMLDocument.load(filename)
---> do some blaaaaah
CoUninitialize();
still memory leaks. i tried to create a global pointer to pXMLDocument, same effect. does ist store internal data, how can i free it....
-
July 18th, 2005, 04:16 PM
#4
Re: Memory leak in loadxml?
Did you do pXMLDocument.Release() at the end? Otherwise that object doesn't get freed properly.
Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
Supports C++ and VB out of the box, but can be configured for other languages.
-
July 19th, 2005, 01:57 AM
#5
Re: Memory leak in loadxml?
hi, i used smartpointer. this type releases itself when my function is finished. i see him walking through release. well, i will try to use normal com pointer. but i guess thats not it.
-
July 19th, 2005, 03:13 AM
#6
Re: Memory leak in loadxml?
 Originally Posted by LaxRoth
hi, i used smartpointer. this type releases itself when my function is finished. i see him walking through release. well, i will try to use normal com pointer. but i guess thats not it.

Fine do one thing
it happens due to LoadXml
when you are loading a xml by LoadXml
after finishing your work just check it out still file exist and that's why i think u rgetting error
it's aloop hole of microsoft
better
after finishing your work do this
pXMLDocument->loadXML(CComBSTR(""), &bSuccessful );
pXMLDocument = NULL;
::CoUninitialize();
Load a empty string
and your memory leakage will remove.
hopefully this will help you
-
July 19th, 2005, 04:15 AM
#7
Re: Memory leak in loadxml?
hi,
if i call pXMLDocument->loadXML(BSTR(""));
i get some exceptions:
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
memory still remains high.
-
July 19th, 2005, 05:08 AM
#8
Re: Memory leak in loadxml?
 Originally Posted by LaxRoth
hi,
if i call pXMLDocument->loadXML(BSTR(""));
i get some exceptions:
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
Nicht abgefangene Ausnahme in kp32sqke.exe (KERNEL32.DLL): 0xE0000001: (kein Name).
memory still remains high.
are you sure.
check it out once again and this code is one of my working project
-
July 19th, 2005, 05:12 AM
#9
Re: Memory leak in loadxml?
very sure.
currently i import msxml.dll:
#import "msxml.dll" named_guids
create smartptr:
MSXML::IXMLDOMDocumentPtr pXMLDocument (__uuidof (MSXML: OMDocument)); // main document parsed
load xml from file:
hr = pXMLDocument->load (filename); /* trying parse string, if success, we have doc object*
your suggestion:
pXMLDocument->loadXML("");
pXMLDocument = NULL;
i have also tried with MSXML2:: namespace, same effect.
its too my working project...
-
July 19th, 2005, 07:25 AM
#10
Re: Memory leak in loadxml?
 Originally Posted by LaxRoth
very sure.
currently i import msxml.dll:
#import "msxml.dll" named_guids
create smartptr:
MSXML::IXMLDOMDocumentPtr pXMLDocument (__uuidof (MSXML:  OMDocument)); // main document parsed
load xml from file:
hr = pXMLDocument->load (filename); /* trying parse string, if success, we have doc object*
your suggestion:
pXMLDocument->loadXML("");
pXMLDocument = NULL;
i have also tried with MSXML2:: namespace, same effect.
its too my working project...

due to xml version effect check with this
#import <msxml.dll> named_guids
using namespace MSXML;
hr = spDocument.CoCreateInstance(CLSID_DOMDocument);
hr = spDocument->load(CComVariant(strpath), &bSuccess);
if still getting problem
please post your code
Last edited by humptydumpty; July 19th, 2005 at 07:30 AM.
-
July 19th, 2005, 07:40 AM
#11
Re: Memory leak in loadxml?
 Originally Posted by humptydumpty
due to xml version effect check with this
#import <msxml.dll> named_guids
using namespace MSXML;
hr = spDocument.CoCreateInstance(CLSID_DOMDocument);
hr = spDocument->load(CComVariant(strpath), &bSuccess);
if still getting problem
please post your code
sorry what is spDocument ?
-
July 19th, 2005, 07:43 AM
#12
Re: Memory leak in loadxml?
 Originally Posted by LaxRoth
sorry what is spDocument ?
spDocument Object of IXMLDOMDocument
CComPtr<IXMLDOMDocument> spDocument;
-
July 20th, 2005, 02:27 AM
#13
Re: Memory leak in loadxml?
 Originally Posted by LaxRoth
hi, i used smartpointer. this type releases itself when my function is finished. i see him walking through release. well, i will try to use normal com pointer. but i guess thats not it.

My point is that if you do everything in main(), then the document won't get released until after main() has finished and so it didn't get released before calling CoUnintialize.
Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
Supports C++ and VB out of the box, but can be configured for other languages.
-
July 20th, 2005, 02:33 AM
#14
Re: Memory leak in loadxml?
hi, i see the com pointer walking through release...its not called in main function. i will try in separate project. meanwhile i post som xml...is this correct syntax???
or maybe the files are wrong?
<?xml version='1.0' encoding='Windows-1250'?>
<connection>
<TXTXMLRow refid='1' ID='dpe' DbSystem='SQLServer' Db='dpe' ConnType='ADO' DSN='nblb' PhysUser='sa' PhysPwd='sa' active='No' activedb='No'/>
<TXTXMLRow refid='3' ID='ADIMP' DbSystem='Sybase' Db='ADIMP' ConnType='ODBC' DSN='ADIMP' PhysUser='sa' PhysPwd='opensoft' active='No' activedb='No'/>
<TXTXMLRow refid='4' ID='ADROB' DbSystem='Sybase' Db='ADROB' ConnType='ODBC' DSN='ADROB' PhysUser='sa' PhysPwd='opensoft' active='No' activedb='No'/>
</connection>
-
July 20th, 2005, 02:52 AM
#15
Re: Memory leak in loadxml?
 Originally Posted by LaxRoth
hi, i see the com pointer walking through release...its not called in main function. i will try in separate project. meanwhile i post som xml...is this correct syntax???
or maybe the files are wrong?
<?xml version='1.0' encoding='Windows-1250'?>
<connection>
<TXTXMLRow refid='1' ID='dpe' DbSystem='SQLServer' Db='dpe' ConnType='ADO' DSN='nblb' PhysUser='sa' PhysPwd='sa' active='No' activedb='No'/>
<TXTXMLRow refid='3' ID='ADIMP' DbSystem='Sybase' Db='ADIMP' ConnType='ODBC' DSN='ADIMP' PhysUser='sa' PhysPwd='opensoft' active='No' activedb='No'/>
<TXTXMLRow refid='4' ID='ADROB' DbSystem='Sybase' Db='ADROB' ConnType='ODBC' DSN='ADROB' PhysUser='sa' PhysPwd='opensoft' active='No' activedb='No'/>
</connection>
Better it you put your file.
then it's easy to find actual error.
because all possibilities are discussed here.
now without seen the project i don't think that anyone can tell you exact problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|