This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Memory leaks in standard code


FX wrote:
 REAL, ALLOCATABLE :: A(:)
 DO WHILE(!condition)
   ! Do something
   ALLOCATE(A(50))
 END DO
 END

generates a memory leak, unless ALLOCATE guards against this.

Yeah, I should have said something about this... we already detect two cases: ALLOCATE(already_allocated_array) and DEALLOCATE(non_allocated_array). Are there any more?

Thanks,
FX


real, pointer :: A(:)


do
  allocate(a(50))
  nullify(a)
end do

That'll leak like a sieve. ;)

--
Dr David Ham
Applied Modelling and Computation Group,
Department of Earth Science and Engineering,
Imperial College London,

http://amcg.ese.ic.ac.uk/index.php?title=David_Ham


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]