www.digitalmars.com         C & C++   DMDScript  

D - Crash when allocating >65K objects

reply Bill Cox <bill viasic.com> writes:
It's probably something dumb in my setup, but just in case, here's a 
simple bug I've run into.

I was trying to benchmark GC, but anything that allocates over about 65K 
objects crashes.  Here's a simple example:

class Foo {
     int a, b, c;
}

int main(char[][] args)
{
     Foo foo;
     int i;

     for(i = 0; i < 100000; i++) {
	printf("i = %d\n", i);
         foo = new Foo;
     }
     return 0;
}

When I run it, it crashes with the last output looking like:

i = 65148
i = 65149
i = 65150
i = 65151
Segmentation fault
Jul 30 2003
parent Burton Radons <loth users.sourceforge.net> writes:
Bill Cox wrote:

 It's probably something dumb in my setup, but just in case, here's a 
 simple bug I've run into.
 
 I was trying to benchmark GC, but anything that allocates over about 65K 
 objects crashes.  Here's a simple example:
 
 class Foo {
     int a, b, c;
 }
 
 int main(char[][] args)
 {
     Foo foo;
     int i;
 
     for(i = 0; i < 100000; i++) {
     printf("i = %d\n", i);
         foo = new Foo;
     }
     return 0;
 }
Works for me. Make sure you've got DMD 0.68.
Jul 30 2003