With the very simple generation program listed below, I generated a 3GB
file. I removed the "break" from your test program to make it read the
whole thing, and it did so in a couple of minutes (during which the
disk was constantly active). Memory stayed constant (and low)
throughout.
Jon,
I made some good progress, thanks to your generate program. Seems that
mine was the problem. I put the code below. Not sure what the
underlying problem with it is. One difference is that it writes with
the streamwriter, not textwriter. another is that it writes each
element on a separate line.
I used your program but changed the tag names to what I was using,
added spaces for indents, added two more levels, but put it all on one
line and I have no problem reading the output file upto 3Gb so far.
I should add that using my CreateRawXml method, I generated a small
file with the same structure and IE had no problem with it -I did this
to see if I had violated a tag name rule or orther rule of some sort.
So what do you think caused the problem I had?
Bill
public class BuildRawXml
{
private UInt64 maxNodes = 10000;
private UInt64 maxChildren = 150;
private UInt64 maxGrandchildren = 4;
private UInt64 maxGreatGC = 1;
private string root = "<root>";
private string rootEndTag = "</root>";
public void CreateRawXml()
{
string fname = @"C:\Development\BuildXml\BuildXml\bin\Debug
\big10K 100 4 1.xml";
StreamWriter sw = new StreamWriter(fname);
sw.WriteLine(root);
AddNodes(sw);
sw.WriteLine(rootEndTag);
sw.Close();
}
private void AddNodes(StreamWriter sw)
{
string child = string.Empty;
string startTag = "<";
string closeTag = ">";
string EndTag = " />";
string endElementTag = "</";
string grandchild = string.Empty;
string Greatgrandchild = string.Empty;
string GreatGC = string.Empty;
string text = "text for ";
for (UInt64 i = 0; i < maxNodes; i++)
{
child = "Child" + Convert.ToString(i) ;
sw.WriteLine(Indent(2) + startTag + child +
closeTag);
for (UInt64 j = 0; j < maxChildren; j++)
{
grandchild = child + "_GC" +
Convert.ToString(j);
sw.WriteLine(Indent(4) + startTag + grandchild +
closeTag);
//XmlNode textnode =
grandchild.OwnerDocument.CreateTextNode(text);
//grandchild.AppendChild(textnode);
for (UInt64 k = 0; k < maxGrandchildren; k++)
{
Greatgrandchild = grandchild + "_GGC" +
Convert.ToString(k);
sw.WriteLine(Indent(6) + startTag +
Greatgrandchild + closeTag);
for (UInt64 l = 0; l < maxGreatGC; l++)
{
GreatGC = Greatgrandchild + "_GGGC" +
Convert.ToString(l);
if(string.IsNullOrEmpty(text))
{
sw.WriteLine(Indent(8) + startTag +
GreatGC + EndTag);
}
else{
sw.WriteLine(Indent(8) + startTag +
GreatGC + closeTag + text + GreatGC + endElementTag + GreatGC +
closeTag);
}
}
sw.WriteLine(Indent(6) + endElementTag +
Greatgrandchild + closeTag);
}
sw.WriteLine(Indent(4) + endElementTag +
grandchild + closeTag);
}
sw.WriteLine(Indent(2) + endElementTag + child +
closeTag );
}
}
private string Indent(int offset)
{
return( new string(Convert.ToChar(" "), offset) );
}
public void Generate()
{
string fname = @"C:\Development\BuildXml\BuildXml\bin\Debug
\test4.xml";
TextWriter tr = new StreamWriter(fname);
tr.WriteLine("<root>");
for (int i = 0; i < 40000000; i++)
{
tr.WriteLine("<Child> <gc> <ggc> <gggc>some
text</gggc></ggc></gc></Child>");
}
tr.WriteLine("</root>");
tr.Close();
}
}