# Best practice: Deallocating allocatable arrays explicitly vs implicitly

**URL:** <https://fortran-lang.discourse.group/t/best-practice-deallocating-allocatable-arrays-explicitly-vs-implicitly/3071>\
**Category:** Help\
**Created:** [March 30, 2022, 9:13am UTC](https://fortran-lang.discourse.group/t/best-practice-deallocating-allocatable-arrays-explicitly-vs-implicitly/3071 "2022-03-30T09:13:33Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![shahmoradi](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahmoradi/32/3151_2.png) [@shahmoradi](https://fortran-lang.discourse.group/u/shahmoradi)\
**Post date:** [March 31, 2022, 3:17am UTC](https://fortran-lang.discourse.group/t/best-practice-deallocating-allocatable-arrays-explicitly-vs-implicitly/3071/8 "2022-03-31T03:17:44Z")

</div>

I would only remind you that you do not get the choice of implicit deallocation in procedures when compiling with gfortran using heap arrays (`gfortran -fmax-stack-var-size=10 main.f90 -o`). To me, this seems to be a bug in gfortran. Intel ifort compiler has no issues with it.

```fortran
    call testAutoDealloc
    call testAutoDealloc
contains
    subroutine testAutoDealloc
        real, allocatable :: temp(:)
        allocate(temp(200))
        !deallocate(temp)
    end
end

```

> **[Compiler Explorer - Fortran (x86-64 gfortran (trunk))](https://godbolt.org/z/9z48Tze8c)**
>
> call testAutoDealloc
> call testAutoDealloc
> contains
> subroutine testAutoDealloc
> real, allocatable :: temp(:)
> allocate(temp(200))
> end
> end

---

_[View the full topic](https://fortran-lang.discourse.group/t/best-practice-deallocating-allocatable-arrays-explicitly-vs-implicitly/3071)._
