www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [memory allocation] system freezing?

reply Manfred Nowak <svv1999 hotmail.com> writes:
On my win98 system this D program frozed the system. To watch the 
freezing the program can be given an upper bound for normal 
growing.
When reaching this upper bound the growing will be done element by 
element.

On win xp pro I have not reached that critical point or it might 
not even exist because win98 was flawed.

<code>
private import std.c.stdio, std.conv;

class C{}
C[] a;

void main(char[][] args)
{
    int delta= 100000;
    while(1)
    {
       try{
         if( args.length>1 && a.length >= toInt(args[1])) delta= 1;
         a.length = a.length + delta;
         fprintf(stderr,"%d ", a.length);
       }
       catch
       {
          printf("Allocated array of length %d.\n", a.length);
          break;
       }
    }
}
</code>
Apr 22 2005
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Manfred Nowak schrieb am Fri, 22 Apr 2005 07:15:53 +0000 (UTC):
 On my win98 system this D program frozed the system. To watch the 
 freezing the program can be given an upper bound for normal 
 growing.
 When reaching this upper bound the growing will be done element by 
 element.

 On win xp pro I have not reached that critical point or it might 
 not even exist because win98 was flawed.

<code>
 private import std.c.stdio, std.conv;

 class C{}
 C[] a;

 void main(char[][] args)
 {
     int delta= 100000;
     while(1)
     {
        try{
          if( args.length>1 && a.length >= toInt(args[1])) delta= 1;
          a.length = a.length + delta;
          fprintf(stderr,"%d ", a.length);
        }
        catch
        {
           printf("Allocated array of length %d.\n", a.length);
           break;
        }
     }
 }
</code>

Seems to be OS dependent. On linux the programm was killed without entering the catch block. Added to DStress as http://dstress.kuehne.cn/run/OutOfMemory_03.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCafIL3w+/yD4P9tIRAk2YAJ4wveuKV3On6aP4Ka1XgeZtO1NW+QCgm/Nz LQ2csPmMesj1UfK9c7WjhgQ= =zR3o -----END PGP SIGNATURE-----
Apr 22 2005