www.digitalmars.com         C & C++   DMDScript  

D - [bug?] gc does not throw Out Of Memory

Running this code with some high parameter my system was set with a
remaining free space of 40 MB out of 400 MB on the harddisk and the
executable doing nothing anymore. I would expect the executable to throw
OutOfMemmory exception.

private import std.c.stdio, std.conv;
class foo
{
}

foo[] fooa;

int main(char[][] args)
{
    int delta= 100_000;
    while(1)
    {
       try{
         if( fooa.length >= toInt(args[1])) delta= 1;
         fooa.length = fooa.length + delta;
         fprintf(stderr,"%d ", fooa.length);
       }
       catch
       {
          printf("Allocated %d instances of foo.\n", fooa.length);
          break;
       }
    }

    return 0;
}
Mar 30 2004