Bugzilla – Bug 314759
Memory demanding console program crashes with gc error
Last modified: 2007-09-24 14:18:40 UTC
---- Reported by tomas.kukol@volny.cz 2004-05-18 10:22:50 MST ---- 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--------------------------------------------------------- ---- Additional Comments From lupus@ximian.com 2004-05-18 11:22:04 MST ---- It works fine on Linux. What version of libgc did you use? It's either old or miscompiled or there may be a win32-specific bug in it. Try with a recent one from http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/. ---- Additional Comments From tomas.kukol@volny.cz 2004-05-18 12:05:25 MST ---- I have installed Mono from binary package mono-Beta1-win32-2.exe (http://www.go-mono.com/archive/beta1/windows/mono-Beta1-win32-2.exe). I cannot find any relevant information about version of libgc. There is only gc.dll in $MONO_PATH/bin directory and it has date of creation 2002-03-18 17:21:04. ---- Additional Comments From bmaurer@users.sf.net 2004-11-22 22:00:06 MST ---- This works for Atsushi with windows today... Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>Windows 2000 Prof US with SP4, MS .NET 1.1, Mono Beta 1</cf_op_sys_details>
*** This bug has been marked as a duplicate of bug 324318 ***