Hello,
I have an ASP.Net app pulling a large XML stream (50 MB) and loading into an
XmlDocument object. Doing so seems to allocate several hundred MBs of
virtual memory (Seen as "virtual bytes" in perfmon). This behavior seems to
happen in the XmlDocument.Load() method.
When the XmlDocument object goes out of scope, the application releases the
"working set" after a period of time, or immediately if I call GC.Collect(),
but the allocated "virtual bytes" remain.
Loading the same XML stream again seems to re-use the allocated virtual
memory, but loading a different XML stream allocates even more virtual
memory. Eventually the application throws an OutOfMemory exception.
Why is the app not releasing the virtual memory as it reaches is memory
limits?
How can I tell the application to release the virtual memory?
Is there something about the XmlDocument object I should know?
Any commands in WinDbg that might help me see what is in virtual memory?
Thanks,
Mike
Manish Bafna - 28 Jun 2007 12:42 GMT
Hi,
ClrProfiler is cool tool which you can use to debug memory problems. You can
use CLR Profiler to identify code that causes memory problems, such as memory
leaks and excessive or inefficient garbage collection.Below link shows how to
use CLRProfiler tool:
http://msdn2.microsoft.com/en-us/library/ms979205.aspx
Also below link provides suggestion to tackle your problem:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=994595&SiteID=1

Signature
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
> Hello,
>
[quoted text clipped - 22 lines]
> Thanks,
> Mike
Mike - 02 Jul 2007 18:52 GMT
Manish, Thank you for your reply.
I tried using CLR profiler and other profilers, but could only seem to see
managed memory. The virtual memory seems to remain after an explicit
GC.Collect, so I'm suspicious my leak is unmanaged memory. Is there some way
to view virtual unmanaged memory in the CLR profiler?
Mike
> Hi,
> ClrProfiler is cool tool which you can use to debug memory problems. You can
[quoted text clipped - 31 lines]
> > Thanks,
> > Mike
Brandon Arp - 11 Jul 2007 19:01 GMT
Mike,
Are you stuck on using an XmlDocument object? This object uses a
considerable amount of memory to parse and hold the document in memory.
Have you checked out the XmlTextReader class? The XmlTextReader class has a
much lower memory use (and usually faster) than the XmlDocument. If you are
not editing the document, this may be the way to go for you. Even if you
are editing, it may be possible to use this class. While this will not
address a memory leak issue, it might serve as a suitable workaround.
Brandon
Fluent Edge Technologies, Inc.
The Ecometry Experts
www.fluentedge.com