[Mono-list] Unable to create more than 1000 objects.

Simon Lindgren simon.n.lindgren at gmail.com
Mon Dec 12 04:46:30 EST 2011


Your test program does not fit your description very well, only creating
10000 objects and that Unit being of ~4MB size instead of 100B.

I could only test up to 4GB of memory since that is the limit of the
mono in the Fedora 16 repos, but for me the run time seems to scale
linearly with growing length of the Unit array. My adapted test code
(with much smaller object size to exaggerate object construction):

using System;

class Test {
  static Unit[] units = new Unit[50000000];
  static public void Main () {
    for (int i = 0; i < units.Length; i++) units[i] = new Unit();
    Console.WriteLine("Now having " + units.Length + " units. " + (GC.GetTotalMemory(false) / 1000000).ToString() + " MB");	
  }
}
  
class Unit {
  int[] dummy = new int[1];
}

time mono --gc=sgen memtest.exe
Now having 50000000 units. 3612 MB
mono --gc=sgen memtest.exe  11,98s user 0,93s system 179% cpu 7,214 total

An observation:
3612000000 bytes / 50000000 objects = 72 bytes/object
72 bytes - 20 bytes = 52 bytes overhead in object instance storage.

Obviously, this does not test memory size scalability of the mono
runtime (at least it does not push it very far). However, with your test
program, increasing the length of the unit array and decreasing the size
of the integer array inside unit will quickly mean that the performance
get dominated by IO performance.

I'm by no means a mono expert, but seeing some actual numbers would be
interesting (and might also help others with more expertise than me).

sön 2011-12-11 klockan 17:16 -0800 skrev Dragony:
> Hi.
> 
> I am running mono under linux Debian, newest version. I wonder if mono is
> unable to use my 64 gb of ram equally. I need around 500 million objects,
> each has around 100 bytes. I thought time has come where OOP can be used for
> making my life easier, but seems not so :(
> 
> I managed to create 500 million empty objects, but as soon as I add
> attributes, the number of objects I can create decreases drastically. I have
> written a short program to show you what I mean.
> 
> PS: I tried sgen GC, this works a little bit better, which means it works
> for the test program, but to create 500 million small objects its slow as
> hell.....
> 
> using System;
> 
> class Test {
>   static Unit[] units = new Unit[10000];
>   static public void Main () {
>     for (int i = 0; i < 10000; i++) units[i] = new Unit();
>   }
> }
>   
> class Unit {
> // dummy array/crashes after/memory consumption when crashing
> //  1 million = 955 units = 3822 mb
> //  2 million = 905 units = 7243 mb
> //  3 million = 887 units = 10645 mb
> //  4 million = 856 units = 13699 mb
> //  5 million = 510 units = 10200 mb
> //  6 million = 515 units = 12361 mb
> // 10 million = 508 units = 20321 mb
> // 15 million = 508 units = 30481 mb
> // 20 million = 508 units = 40641 mb
> // 25 million = 508 units = 50802 mb
> // 30 million = 508 units = 60960 mb
> 
>   int[] dummy = new int[1000000]; // Change this number to test. Above are
> tested examples on a 64GB machine.
>   static int units = 0;
> 
>   public Unit() {
>     Console.WriteLine("Now having " + ++units + " units. " +
> (GC.GetTotalMemory(false) / 1000000).ToString() + " MB");
>   }
> }
> 
> /* Above examples tested with:
> Mono JIT compiler version 2.10.5 (Debian 2.10.5-1)
> Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors.
> www.mono-project.com
>         TLS:           __thread
>         SIGSEGV:       altstack
>         Notifications: epoll
>         Architecture:  amd64
>         Disabled:      none
>         Misc:          softdebug
>         LLVM:          supported, not enabled.
>         GC:            Included Boehm (with typed GC and Parallel Mark)
> */
> 
> 
> 
> --
> View this message in context: http://mono.1490590.n4.nabble.com/Unable-to-create-more-than-1000-objects-tp4184397p4184397.html
> Sent from the Mono - General mailing list archive at Nabble.com.
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list


-- 
Simon Lindgren



More information about the Mono-list mailing list