Re: Allocatable Components of Derived Type
- From: Oskar Enoksson <enok_tabortmig@xxxxxxxxxxxxxx>
- Date: Fri, 12 Oct 2007 13:38:31 +0200
Richard Maine wrote:
Oskar Enoksson <nobody@xxxxxxxxxxx> wrote:
Richard Maine wrote:
2. You can generalize that to all uses of allocatable. AllocatablesOne exception I guess is an allocatable array declared in a subroutine
don't cause memory leaks. Unless, of course, there is a compiler bug.
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.
Yes. And no, I don't know of any unplugged hole. But do you recommend to generally trust the compiler by never deallocating an allocatable variable explicitly?
/Oskar
.
- Follow-Ups:
- Re: Allocatable Components of Derived Type
- From: Richard Maine
- 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
- Re: Allocatable Components of Derived Type
- From: Richard Maine
- Allocatable Components of Derived Type
- Prev by Date: Re: gfortran: bug or non-standard syntax?
- Next by Date: Re: CVF 6.6C Error Message - Negation of '/NoF66' switch not allowed
- Previous by thread: Re: Allocatable Components of Derived Type
- Next by thread: Re: Allocatable Components of Derived Type
- Index(es):
Relevant Pages
|