[Mono-list] My program randomly doesn't work with Mono
Ted Milker
ted at dsndata.com
Wed May 16 11:54:41 EDT 2007
Just an FYI but none of these crash on FreeBSD 6.2 running mono 1.2.3.1
Jonathan Gagnon wrote:
> Hi,
>
> I too have different behaviors if I put a Console.WriteLine in my code.
> Consider the following example :
>
> static void Main(string[] args)
> {
> int num = 5000000;
> Hashtable table = new Hashtable();
> for (int i = 0; i < num; ++i)
> {
> Object obj = new Object();
> table.Add(obj, obj);
> }
> }
>
> That crashes somewhere inside the for loop. But if I add a WriteLine at the
> beginning like this :
>
> static void Main(string[] args)
> {
> int num = 5000000;
> Console.WriteLine("WriteLine");
> Hashtable table = new Hashtable();
> for (int i = 0; i < num; ++i)
> {
> Object obj = new Object();
> table.Add(obj, obj);
> }
> }
>
> Everything works fine. Then if I add another WriteLine at the end followed
> by a Thread.Sleep, it crashes again, but this time inside the Thread.Sleep :
>
> static void Main(string[] args)
> {
> int num = 5000000;
> Console.WriteLine("WriteLine");
> Hashtable table = new Hashtable();
> for (int i = 0; i < num; ++i)
> {
> Object obj = new Object();
> table.Add(obj, obj);
> }
> Console.WriteLine("WriteLine");
> Thread.Sleep(10000);
> }
>
> Any modifications to that code may lead to different behaviors. Sometimes I
> seem to end up being stuck in a infinite loop (with 2.8 gig of allocated
> virtual memory). It seems like the size of the executable has an impact on
> the result...
>
More information about the Mono-list
mailing list