mortenbpost
mortenbpost

Reputation: 1707

XDocument memory usage problem

I have a small application that builds up a xml document using XDocument. However, after a while the app is using more than 1gb ram.

So I was wondering if there is anyway to make XDocument use the disk instead of in-memory. For example by opening a StreamWriter and save it to a file on the go.

Thank you in advance.

Upvotes: 2

Views: 1363

Answers (2)

Richard Ev
Richard Ev

Reputation: 54117

Are you sure that your document is so large as to consume 1 GB of memory?

Using a memory profiling tool such as ANTS Memory Profiler might help you discover what objects are remaining in memory.

Upvotes: 2

David Schmitt
David Schmitt

Reputation: 59346

Assuming you refer to the .net XDocument, you can instead use a XmlWriter (tutorial). The XmlWriter can be attached to any stream you like by using the XmlWriter.Create() method.

Upvotes: 1

Related Questions