[Mono-bugs] [Bug 58650][Nor] New - Memory demanding console program crashes with gc error
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Tue, 18 May 2004 10:22:51 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by tomas.kukol@volny.cz.
http://bugzilla.ximian.com/show_bug.cgi?id=58650
--- shadow/58650 2004-05-18 10:22:51.000000000 -0400
+++ shadow/58650.tmp.24690 2004-05-18 10:22:51.000000000 -0400
@@ -0,0 +1,206 @@
+Bug#: 58650
+Product: Mono: Runtime
+Version: unspecified
+OS:
+OS Details: Windows 2000 Prof US with SP4, MS .NET 1.1, Mono Beta 1
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: tomas.kukol@volny.cz
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Memory demanding console program crashes with gc error
+
+Description of Problem:
+
+Memory demanding console program (which was compiled in MS .NET 1.1)
+crashes during test. It adds millions of items into ArrayList and custom
+arraylist-like class. It is intended for performance comparison between
+Mono and MS .NET (runs well on MS .NET 1.1).
+
+Steps to reproduce the problem:
+
+1. Compile code bellow.
+2. Run it.
+3. During first test it should crash.
+
+Actual Results:
+
+WARMUP: 1x 1000 cycles
+Test_ColArray() [time: 15 ms]
+Test_ArrayList() [time: 15 ms]
+
+Test 1: 10x 1000000 cycles
+Test_ColArray() [time: 2875 ms]
+
+In this moment program crashes showing following dialog:
+Title: Fatal error in gc
+Text: Too many heap sections
+
+Expected Results:
+
+WARMUP: 1x 1000 cycles
+Test_ColArray() [time: 15 ms]
+Test_ArrayList() [time: 0 ms]
+
+Test 1: 10x 1000000 cycles
+Test_ColArray() [time: 1187 ms]
+Test_ArrayList() [time: 3968 ms]
+
+Test 2: 100x 100000 cycles
+Test_ColArray() [time: 1390 ms]
+Test_ArrayList() [time: 3296 ms]
+
+Test 3: 1000x 10000 cycles
+Test_ColArray() [time: 1046 ms]
+Test_ArrayList() [time: 2109 ms]
+
+Test 4: 10000x 1000 cycles
+Test_ColArray() [time: 1328 ms]
+Test_ArrayList() [time: 1859 ms]
+
+Test 5: 100000x 100 cycles
+Test_ColArray() [time: 1343 ms]
+Test_ArrayList() [time: 1671 ms]
+
+Test 6: 1000000x 10 cycles
+Test_ColArray() [time: 1234 ms]
+Test_ArrayList() [time: 1656 ms]
+
+Press return...
+
+How often does this happen?
+
+Everytime I run the program.
+
+Additional Information:
+
+There is code which produce described behaviour:
+
+//---codebegin---------------------------------------------------------
+using System;
+using System.Collections;
+
+namespace KukiCZ.Performance
+{
+ class ArrayListRealocTestApp
+ {
+ [STAThread]
+ static void Main(string[] args)
+ {
+ mRandom = new Random();
+
+ Test("WARMUP", 1, 1000);
+
+ Test("Test 1", 10, 1000000);
+ Test("Test 2", 100, 100000);
+ Test("Test 3", 1000, 10000);
+ Test("Test 4", 10000, 1000);
+ Test("Test 5", 100000, 100);
+ Test("Test 6", 1000000, 10);
+
+ Console.Write("Press return...");
+ Console.ReadLine();
+ }
+
+ private static void ShowTime(DateTime dStart, DateTime dStop, string text)
+ {
+ Console.WriteLine("{0,-20} [time: {1,5} ms]", text, ((dStop.Ticks -
+dStart.Ticks) / 10000).ToString());
+ }
+
+ private static void Start()
+ {
+ mStart = DateTime.Now;
+ }
+
+ private static void Stop(string text)
+ {
+ mStop = DateTime.Now;
+ ShowTime(mStart, mStop, text);
+ }
+
+ private static void Test_ArrayList(int outerCount, int innerCount)
+ {
+ Start();
+ for (int j = 0; j < outerCount; j++)
+ {
+ ArrayList a = new ArrayList();
+ for (int i = 0; i < innerCount; ++i)
+ {
+ a.Add(mRandom.Next());
+ }
+ }
+ Stop("Test_ArrayList()");
+ }
+
+ private static void Test_ColArray(int innerCount, int outerCount)
+ {
+ Start();
+ for (int j = 0; j < outerCount; j++)
+ {
+ ColArray c = new ColArray();
+ for (int i = 0; i < innerCount; ++i)
+ {
+ c.Add(mRandom.Next());
+ }
+ }
+ Stop("Test_ColArray()");
+ }
+
+ private static void Test(string testName, int inner, int outer)
+ {
+ Console.WriteLine("{0}: {1}x {2} cycles",
+ testName, inner.ToString(), outer.ToString());
+
+ Test_ColArray(inner, outer);
+ Test_ArrayList(inner, outer);
+
+ Console.WriteLine();
+ }
+
+ private static DateTime mStart, mStop;
+ private static Random mRandom;
+ }
+
+ public class ColArray
+ {
+ public ColArray()
+ {
+ mSize = mInit;
+ mHolder = new int[mSize];
+ }
+
+ public int this [int index] { get { return mHolder[index]; } }
+
+ public void Add(int aValue)
+ {
+ mHolder[mLength++] = aValue;
+ if (mLength == mSize) {
+// mSize += mStep;
+// mSize += Convert.ToInt32((mSize * 0.1) + 0.5);
+// mSize += (mSize / 2);
+ mSize *= 2;
+
+ int[] newArr = new int[mSize];
+ mHolder.CopyTo(newArr, 0);
+ mHolder = newArr;
+ }
+ }
+
+ public int Length { get { return mLength; } }
+
+ protected static int mInit = 16;
+ protected static int mStep = 32;
+
+ private int mSize;
+ private int mLength;
+ private int[] mHolder;
+ }
+}
+//---codeend---------------------------------------------------------