Re: Possible memory leak?
On Jul 22, 11:40 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
James Kanze wrote:
Of course, under a well behaved operating system, nothing
leaks, even if a process terminates abnormally.
No OS can know if the program created some temporary files
which it intends to delete when it terminates.
Sure it can. Perhaps the most common OS's don't do this, but
they certainly could (and I've used at least one OS which did).
For that matter, it's possible to do so under Unix (but only to
a limited extent).
More generally, of course, you're right in that there will
always be some resources for which it isn't clear whether they
should remain or not. g++ (and probably many other compilers)
has an option to explicitly not delete intermediate files; if
something crashes, they can be very useful for debugging. Is
this a resource leak? I'd say yes, but an intentional one.
For that matter, if I don't catch an exception under Unix, I get
a core dump, which can eat up considerable resources.
Within the context of the original posting, however: if a
program terminates because of an uncaught exception, the system
should recover all of the critical resources, without a stack
walkback, and a stack walkback is likely to destroy resoures,
and above all context, that you want to keep, for debugging
purposes. The standard makes it implementation defined (or
unspecified, I'm not sure) whether there is a stack walkback in
such cases, but from a quality of implementation point of view,
I think not walking back the stack is to be preferred.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34