MSXML2 - XML parser Memory Leak
-
Hi, We are using Microsoft provided DOM parser - MSXML2 version 4(or 40) When we are saving XML file, we are generating whole new file including all nodes and elements. Size of XML file is 3.5 MB. So it is taking 350 MB memory (both virtual as well as physical) Once save is done we are releasing all the XML objects. But there is no change happening in memory. So every consecutive save keeps on increasing memory by 350MB (approx) After 3-4 save we have to restart application again. We have seen that if we minimize the application physical memory is coming back to original size (mean additional 350MB is getting reduced) but virtual memory is not changing. I think may be OS have reserved that place for application as memory cleaning is not done properly. But we have make sure that we have release all the memory we use. Some where on some forum we seen a work around like this,
VARIANT_BOOL bstatus;
m_pXMLDomDoc->loadXML(CComBSTR(""), &bstatus );
Release(m_pXMLDomDoc);That guy suggested that after you release saved document try to load a blank file. It will remove uncleaned area. But there is not much improvement. Please let me know if someone can help me.
-
Hi, We are using Microsoft provided DOM parser - MSXML2 version 4(or 40) When we are saving XML file, we are generating whole new file including all nodes and elements. Size of XML file is 3.5 MB. So it is taking 350 MB memory (both virtual as well as physical) Once save is done we are releasing all the XML objects. But there is no change happening in memory. So every consecutive save keeps on increasing memory by 350MB (approx) After 3-4 save we have to restart application again. We have seen that if we minimize the application physical memory is coming back to original size (mean additional 350MB is getting reduced) but virtual memory is not changing. I think may be OS have reserved that place for application as memory cleaning is not done properly. But we have make sure that we have release all the memory we use. Some where on some forum we seen a work around like this,
VARIANT_BOOL bstatus;
m_pXMLDomDoc->loadXML(CComBSTR(""), &bstatus );
Release(m_pXMLDomDoc);That guy suggested that after you release saved document try to load a blank file. It will remove uncleaned area. But there is not much improvement. Please let me know if someone can help me.
Using which tool did you check the Memory usage? If you checking this from the task manager of window XP, I must say that you should consider only the VM usage, the memory usage it specifies is actually Working Set. I dont remeber excatly, but there was problem with DOM parser such that it will release the memory completely only when the thread( that created DOM objects are created) is terminated. You can try like, create a dedicated thread to read the data from the XML and once it is done, end that thread and check whether the memory is back to normal or not( VM size, not Memory usage ).
nave [My Articles] [My Blog]
-
Using which tool did you check the Memory usage? If you checking this from the task manager of window XP, I must say that you should consider only the VM usage, the memory usage it specifies is actually Working Set. I dont remeber excatly, but there was problem with DOM parser such that it will release the memory completely only when the thread( that created DOM objects are created) is terminated. You can try like, create a dedicated thread to read the data from the XML and once it is done, end that thread and check whether the memory is back to normal or not( VM size, not Memory usage ).
nave [My Articles] [My Blog]