Article View: comp.std.c
Article #4042Re: Is malloc()ed storage freed upon program termination?
From: Heath Hunnicutt
Date: Tue, 19 Sep 1995 07:10
Date: Tue, 19 Sep 1995 07:10
22 lines
1397 bytes
1397 bytes
jimh@earth.execpc.com (Jim Hennessy) writes: >Does the C standard guarantee that storage allocated by malloc() is >freed during program termination? If so, where? I can't find it. No, there is no such guarantee. >In other words, is it safe to exit the program without using free() >to deallocate storage which was allocated via malloc()? I know most >operating systems free the storage, but I'm wondering if it's guaranteed, >and thus safe on any operating system. Depends on the OS. It is not guaranteed, and is definitely not safe on DOS and 16-bit Windows. (This does *not* include Windows 95 or Windows NT.) It's also a bad practice, since someone may not realize your functions allocate memory they never free, and might try to use them in some server software. Lots of server programs never exit, and memory leaks in that situation are not fun. Heath
Technical Details
Message-ID:
<43lqdg$c12@gap.cco.caltech.edu>Path:
arc1-ca.pugleaf.net!nntp-server.caltech.edu!heathhReferences:
<43l16d$3dp@homer.alpha.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!nntp-server.caltech.edu!heathh From: heathh@lust.ugcs.caltech.edu (Heath Hunnicutt) Newsgroups: comp.std.c Subject: Re: Is malloc()ed storage freed upon program termination? Date: 19 Sep 1995 07:10:40 GMT Organization: California Institute of Technology, Pasadena Message-ID: <43lqdg$c12@gap.cco.caltech.edu> References: <43l16d$3dp@homer.alpha.net> NNTP-Posting-Host: lust.ugcs.caltech.edu Keywords: malloc, program, process, termination, free X-Newsreader: NN version 6.5.0 #14 (NOV)