C#.Net: Out of memory exception while creating XML string with XML Searlization
Posted on 2012-09-12
I've a project in which I pass collection and it converts in XML string.
But when below method creates 50 to 60 MB files then it does create 2 or 3 files but after that it does day "Out of memory exception"
Note: the machine RAM is 4 GB
I am using below method:
public string ToXMLString(CollectionData data)
StringWriter stringWriter = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(stringWriter);
writer.Formatting = Formatting.Indented;
XmlSerializer serializer = new XmlSerializer(typeof(CollectionData));
string XmlizedString = stringWriter.ToString();
Could you please look into it on urgent basis?