June 29th, 2009, 09:07 AM
how to release the resources of XmlDocument
When I open an xml file using the XmlDocument.Load function, the memory usage increases a lot.
The file I'm opening is size of 10MB. When I open this file in a WinApp, the momory usage increases with about 25mb (the file is only 10MB). I have 3 versions of this file, when I open them all 3 (a few times), the memory is increases about 75MB. In my website it even increases from 100MB to 450-500MB.
Looks like the GC does not collect them. The XmlDocument objects I'm using, are all local variables, thus I know for sure that there is no more reference to the object after the method is executed.
When I'm correctly informed, the GC collects after the method is executed and the local variables aren't in use any more. But when I force the GC using GC.Collect(), the memory usage is decreased a bit (back to 200MB in website), but never gets back to the original 100MB.
I also know that the GC.Collect method shouldn't be used, thus I would like to know if there is any other option that releases the resource of the XmlDocument class?
Am I missing something about the XmlDocument class I should know?
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!