Re: Memory leak in loadxml?
Quote:
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
:mad:
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
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::DOMDocument));
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....
:wave:
Re: Memory leak in loadxml?
Did you do pXMLDocument.Release() at the end? Otherwise that object doesn't get freed properly.
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.
:sick:
Re: Memory leak in loadxml?
Quote:
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.
:sick:
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
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.
Re: Memory leak in loadxml?
Quote:
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
Re: Memory leak in loadxml?
very sure.
currently i import msxml.dll:
#import "msxml.dll" named_guids
create smartptr:
MSXML::IXMLDOMDocumentPtr pXMLDocument (__uuidof (MSXML::DOMDocument)); // 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...
:wave:
Re: Memory leak in loadxml?
Quote:
Originally Posted by LaxRoth
very sure.
currently i import msxml.dll:
#import "msxml.dll" named_guids
create smartptr:
MSXML::IXMLDOMDocumentPtr pXMLDocument (__uuidof (MSXML::DOMDocument)); // 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...
:wave:
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
Re: Memory leak in loadxml?
Quote:
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 ?
Re: Memory leak in loadxml?
Quote:
Originally Posted by LaxRoth
sorry what is spDocument ?
spDocument Object of IXMLDOMDocument
CComPtr<IXMLDOMDocument> spDocument;
Re: Memory leak in loadxml?
Quote:
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.
:sick:
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.
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>
Re: Memory leak in loadxml?
Quote:
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.