Mail Archives: djgpp/1996/05/13/12:45:11
Errors-To: postmaster AT ns1
Xref: news2.mv.net comp.os.msdos.djgpp:3691
From: Rikard Thunberg <thunberg AT algonet DOT se>
Newsgroups: comp.os.msdos.djgpp
Date: Fri, 10 May 1996 13:29:33 +0200
Organization: Informia
Lines: 16
Nntp-Posting-Host: aristotle.algonet.se
Nntp-Posting-User: a37bfb8671f5d77b3
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.01Gold (Win95; I)
Dj-Gateway: from newsgroup comp.os.msdos.djgpp
Content-Type: text/plain; charset=us-ascii
Content-Length: 445
I'm using MSDOS/WIN95.
If I use calloc() to allocate memory I have to
release the memory with free() before my program quit, right?
Well... Not really. All allocated memory will be returned to the DOS and DPMI
memory pools when the application exits even if you never call free(). Hence
your results with mem/c below. Of course, this is REALLY BAD programming. The
only way to ensure that you free all allocated memory is to keep track
yourself, either directly or indirectly. You could always call my_calloc() and
my_malloc() which are macros or inline functions which record and track
allocations and my_free() to track memory releases and then call a function
through atexit() to report unfreed blocks or just the amount of unfreed memory.
For production compiles these could be #defined to the real malloc, calloc,
realloc and free once the memory leaks have been plugged.
How do I verify that my program have released all memory I have allocated?
I have tried following procedure, but without success:
mem/c >mem1.log
my_program.exe
mem/c >mem2.log
mem1.log is equivalent of mem2.log even if I don't use free() in my program!
please help!
/Rikard Thunberg, thunberg AT algonet DOT se
--
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com
A proverb is no proverb to you 'till life has illustrated it. -- John Keats
- Raw text -