Mail Archives: djgpp/1997/03/01/22:13:30
I was wondering: if I allocate some memory with malloc () or an equivalent
function and then quit the program without calling free (), will this
memory be freed automatically?
I searched the djgpp docs and all I could find was this:
"This function allocates a chunk of memory from the heap large enough to
hold any object that is SIZE bytes in length. This memory must be
returned to the heap with `free' (*note free::.)."
Please note that it says "must".
Then I conducted the following test: I run the program which source is
below under both Win95 and plain DOS with CWSDPMI. My computer has 32 MB of
RAM and in both cases I run it about 30 times in a row. The available
memory as reported by MEM.EXE did not shrink a single bit nor there was a
single indication of virtual memory usage like disc activity.
Any comments?
Cristovao Braga.
--- starts here ---
#include <stdlib.h>
char *p;
main ()
{
p = (char *) malloc (5 * 1024 * 1024);
}
- Raw text -