[Mono-bugs] [Bug 70241][Wis] New - The GC commits memory on allocation
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sun, 5 Dec 2004 21:57:49 -0500 (EST)
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 bmaurer@users.sf.net.
http://bugzilla.ximian.com/show_bug.cgi?id=70241
--- shadow/70241 2004-12-05 21:57:48.000000000 -0500
+++ shadow/70241.tmp.17223 2004-12-05 21:57:49.000000000 -0500
@@ -0,0 +1,54 @@
+Bug#: 70241
+Product: Mono: Runtime
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: bmaurer@users.sf.net
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: The GC commits memory on allocation
+
+Consider the following test case:
+
+class X {
+ static void Main ()
+ {
+ int size = int.MaxValue;
+ do {
+ try {
+ int [] x = new int [size];
+
+ x [1] = 1;
+ x [size / 2] = 1;
+ x [size / 3] = 1;
+ x [size - 1] = 1;
+ } catch {
+ }
+ } while ((size >>= 1) != 0);
+ }
+}
+
+In this test, I am creating a very large, but very sparse, array.
+
+What should happen in this case is that only 4 pages get allocated (each
+page that I touched). The other pages should not be comitted to physical
+memory. If you write the test in C and use calloc, this is what happens. On
+MSFT the test case returns instantly, and there is no sign of excess memory
+comitting (at least, according to the task manager)
+
+However, Mono is committing the pages when they are allocated. This uses up
+nearly all the memory on the system.
+
+I am not sure if turnning on mmap support for libgc will fix this. It might
+still clear the pages with memset, which would render this useless.
+
+Even so, we probably want a behavior like libc malloc -- mmap large
+allocations only.