Mail Archives: djgpp/1992/10/12/11:46:38
The following simple program happily allocates memory until my machine dies.
Although i should have no more than approx. 150 MByte (disc + ram), it
allocates more than 300 MB before hanging.
#include <stdio.h>
#include <stdlib.h>
main ()
{
unsigned short int max = ~0; /*should be a block of 64 Kb*/
size_t bytes = max;
unsigned long mem = 0L;
setbuf (stdout,NULL);
while (malloc(bytes))
{
mem += bytes;
printf ("\r%.3f MBytes allocated",mem / 1024. /1024.);
}
}
Any ideas what's going wrong,
Stefan
--
________________________________________________________________________________
Stefan Schwarz University of the armed forces, Munich
Laboratory for graphical data processing W-8014 Neubiberg, FRG
--------------------------------------------------------------------------------
- Raw text -