ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/10/12/11:46:38

From: stefans AT bauv106 DOT bauv DOT unibw-muenchen DOT de (Stefan Schwarz)
Subject: problems with memory allocation
To: djgpp AT sun DOT soe DOT clarkson DOT edu (DJGPP mailing list)
Date: Mon, 12 Oct 92 15:42:39 MET

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019