I have encountered what appears to be a bug in
String.ToCharAr ray, and so far I have not found any
mention or discussion about it. I am interested to know
if anyone else is encountering this problem. I am
using .NET framework 1.1, and Visual Studio 2003. I can
reproduce the problem with a simple C# program:
using System;
namespace ConsoleApplicat ion1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string buffer = new string ( 'M', 12581653 );
char [] chs = buffer.ToCharAr ray ();
Console.WriteLi ne ( "chs Length = {0}",chs.Lengt h );
}
}
}
This will throw an "out of memory" exception on the
ToCharArray call. I actually encountered this problem
trying to parse a large XML fragment - XmlTextReader uses
ToCharArray internally, as does XmlDocument, and both
will crash when presented with an Xml string 12,581,653
characters long.
Interestingly, the act of calling ToCharArray as above
adds about 500MB to the VM Size of my app, as shown in
Task Manager.
String.ToCharAr ray, and so far I have not found any
mention or discussion about it. I am interested to know
if anyone else is encountering this problem. I am
using .NET framework 1.1, and Visual Studio 2003. I can
reproduce the problem with a simple C# program:
using System;
namespace ConsoleApplicat ion1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string buffer = new string ( 'M', 12581653 );
char [] chs = buffer.ToCharAr ray ();
Console.WriteLi ne ( "chs Length = {0}",chs.Lengt h );
}
}
}
This will throw an "out of memory" exception on the
ToCharArray call. I actually encountered this problem
trying to parse a large XML fragment - XmlTextReader uses
ToCharArray internally, as does XmlDocument, and both
will crash when presented with an Xml string 12,581,653
characters long.
Interestingly, the act of calling ToCharArray as above
adds about 500MB to the VM Size of my app, as shown in
Task Manager.
Comment