Re: Allocatable Components of Derived Type
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Wed, 10 Oct 2007 14:56:20 -0700
Oskar Enoksson <nobody@xxxxxxxxxxx> wrote:
Richard Maine wrote:
2. You can generalize that to all uses of allocatable. Allocatables
don't cause memory leaks. Unless, of course, there is a compiler bug.
One exception I guess is an allocatable array declared in a subroutine
with the "SAVE" attribute(?)
No. There are *NO* exceptions.
Such a case will not cause a memory leak, as normally defined. Perhaps
you are talking about the fact that such an array remains allocated
after the return. That's the only thing I can even imagine that you
might be aluding to. That is true, but that does not meet the usual
definition of a memory leak. The memory in question is not "lost". If
you reenter the subroutine, it will still be accessible, that being the
whole point of SAVE. If you try to allocate the array again without
deallocating it first, you won't leak the memory of the first
allocation; instead, you will get an error.
Absent compiler bugs, allocatables do not leak memory. There are no
exceptions. This is by deliberate design. If you actually know of any
exceptions, I'd suggest turning in a defect report to the standard
committee because that would be a defect. It did take a long time to
plug all the holes. I suppose it is vaguely possible that one is left
somewhere, though I don't think so. Certainly it would be nothing as
simple and obvious as a local allocatable variable with the SAVE
attribute. That *IS* a simple case.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- Follow-Ups:
- Re: Allocatable Components of Derived Type
- From: Oskar Enoksson
- Re: Allocatable Components of Derived Type
- References:
- Allocatable Components of Derived Type
- From: tommcd
- Re: Allocatable Components of Derived Type
- From: Richard Maine
- Re: Allocatable Components of Derived Type
- From: Oskar Enoksson
- Allocatable Components of Derived Type
- Prev by Date: Re: Allocatable Components of Derived Type
- Next by Date: Re: equivalence statement my small research
- Previous by thread: Re: Allocatable Components of Derived Type
- Next by thread: Re: Allocatable Components of Derived Type
- Index(es):
Relevant Pages
|