www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/01/06/01:13:48

From: gunter AT statsun DOT stat DOT ColoState DOT EDU (Gunter Hartel)
Subject: alloc's under dpmi
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Date: Thu, 5 Jan 1995 22:29:03 -0700 (MST)

Help, I'm having trouble with dynamically allocating memory.  
	I have a program that needs to repeatedly allocate and free a number of
relatively small blocks of memory (usually less than 200 doubles each).
I am freeing all the blocks that I allocate, so that memory is not
accumulating.  Nonetheless I get GPF's in the allocation or freeing
routines.  I allocate memory using something like:
B = (double *)calloc(m,sizeof(double));
and free the memory using:	cfree(B);
Am I doing something wrong?  I can sometimes run the subroutine over
500 times before it crashes, and depending on small changes in the
block sizes, it might crash after 30 runs.  Also moving the cfree
statement to the end of the routine makes it more stable.  I have 20
megs of RAM and sufficient disk space, so I don't think I'm running
out of memory.  Furthermore, I test if the pointer is NULL and that
is never the case.  Also I use the _go32_dpmi_get_free_memory_information
to find out how much memory is available, and it always gives exactly
the same numbers, before allocating memory, after allocating it, and
after freeing it, the numbers never change.  
	Any advise would be greatly appreciated. Thanks
gunter AT statsun DOT stat DOT colostate DOT edu


- Raw text -


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