Article View: comp.std.c
Article #4041Re: Is malloc()ed storage freed upon program termination?
From: Mark Brader
Date: Tue, 19 Sep 1995 06:13
Date: Tue, 19 Sep 1995 06:13
26 lines
1644 bytes
1644 bytes
Jim Hennessy (jph@vnet.ibm.com) writes: > Does the C standard guarantee that storage allocated by malloc() is > freed during program termination? The question is meaningless. The standard specifies what happens, or may happen, *during* execution of a program, not afterwards. Of course, it is the one of the basic purposes of an operating system to ensure that resources (such as memory) allocated to the execution of a program are reclaimed for use by other programs when it terminates. So if one is running the program under an operating system, one is entitled to assume that memory used by the program, whether allocated by malloc() or not, will be available again when it has terminated. Note that *neither* malloc() nor free() is defined by the C standard in a way that necessarily implies communication with an operating system if one is present (in contrast to fopen(), for example). By the way, this is essentially question 7.24 in the current version of the comp.lang.c FAQ list. -- Mark Brader | "It is impractical for the standard to attempt to msb@sq.com | constrain the behavior of code that does not obey SoftQuad Inc., Toronto | the constraints of the standard." -- Doug Gwyn My text in this article is in the public domain.
Technical Details
Message-ID:
<1995Sep19.061336.21215@sq.com>Path:
arc1-ca.pugleaf.net!howland.reston.ans.net!torn!sq!msbReferences:
<43l16d$3dp@homer.alpha.net>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!howland.reston.ans.net!torn!sq!msb From: msb@sq.com (Mark Brader) Subject: Re: Is malloc()ed storage freed upon program termination? Message-ID: <1995Sep19.061336.21215@sq.com> Organization: SoftQuad Inc., Toronto, Canada References: <43l16d$3dp@homer.alpha.net> Date: Tue, 19 Sep 1995 06:13:36 GMT