Re: Memory leak
Alex wrote:
Is the program still leak memory?
int main()
{
Type *atype = new Type();
// use the atype
....
ruturn 0;
}
The program never call delete but terminate itself. Does the kernel will
close all the open file descriptors for the process and releases all the
memory that it was used?
This is OS-specific, not C++ specific.
However, I remember being involved in a discussion of this topic,
in a C newsgroup, some 10 or 12 years ago; there were people that
emphatically maintained both opinions --- however, the clear majority
insisted that they could not imagine an operating system so mediocre
as to not release the memory. IOW, no, the above should not cause
a OS-level memory manaegment problem with any known minimally decent
operating system.
When you think about is, we're talking about the OS controlling its
own resources (including memory), and the application being just
one "element" that the operating system deals with --- the OS knows
when the application finishes, and it would be just dumb that it
does not act accordingly in terms of knowing that the memory and
resources assigned to that application are no longer in use.
HTH,
Carlos
--
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]