# When I run my proramm with large arrays, when it ends the momory remain allocated

**URL:** <https://discourse.julialang.org/t/when-i-run-my-proramm-with-large-arrays-when-it-ends-the-momory-remain-allocated/16393>\
**Category:** Performance\
**Tags:** array, memory\
**Created:** [October 16, 2018, 9:57am UTC](https://discourse.julialang.org/t/when-i-run-my-proramm-with-large-arrays-when-it-ends-the-momory-remain-allocated/16393 "2018-10-16T09:57:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsHitman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dshitman/32/5465_2.png) [@dsHitman](https://discourse.julialang.org/u/dsHitman)\
**Post date:** [October 16, 2018, 9:57am UTC](https://discourse.julialang.org/t/when-i-run-my-proramm-with-large-arrays-when-it-ends-the-momory-remain-allocated/16393/1 "2018-10-16T09:57:32Z")

</div>

Hi, how I can dealocate memory after I run my programm? Because when I run my ptogramm with big arrays when it ends the memory remain allocated. I try to use the gc() function but Hulia says “ERROR: LoadError: UndefVarError: gc not defined”.  
Thanks.

---

<div class="post-metadata">

**Author:** ![dfdx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dfdx/32/120_2.png) [@dfdx](https://discourse.julialang.org/u/dfdx)\
**Post date:** [October 16, 2018, 10:06am UTC](https://discourse.julialang.org/t/when-i-run-my-proramm-with-large-arrays-when-it-ends-the-momory-remain-allocated/16393/2 "2018-10-16T10:06:37Z")

</div>

1. Unbind all global variables pointing to these arrays.
2. If it doesn’t happen automatically, run `GC.gc()`.

---

<div class="post-metadata">

**Author:** ![dsHitman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dshitman/32/5465_2.png) [@dsHitman](https://discourse.julialang.org/u/dsHitman)\
**Post date:** [October 16, 2018, 10:24am UTC](https://discourse.julialang.org/t/when-i-run-my-proramm-with-large-arrays-when-it-ends-the-momory-remain-allocated/16393/3 "2018-10-16T10:24:59Z")

</div>

I tried to do array = 0 and GC.gc() but in the performance of my PC the memory is alredy allocated and only when I close Julia the memory is deallocated. Thanks for the answer.

---

<div class="post-metadata">

**Author:** ![dfdx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dfdx/32/120_2.png) [@dfdx](https://discourse.julialang.org/u/dfdx)\
**Post date:** [October 16, 2018, 11:10am UTC](https://discourse.julialang.org/t/when-i-run-my-proramm-with-large-arrays-when-it-ends-the-momory-remain-allocated/16393/4 "2018-10-16T11:10:01Z")

</div>

Most likely some other objects are keeping memory from being garbage collected. You can check how much memory is taken by each top-level variable using `varinfo()`.

---

<div class="post-metadata">

**Author:** ![dsHitman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dshitman/32/5465_2.png) [@dsHitman](https://discourse.julialang.org/u/dsHitman)\
**Post date:** [October 17, 2018, 10:51am UTC](https://discourse.julialang.org/t/when-i-run-my-proramm-with-large-arrays-when-it-ends-the-momory-remain-allocated/16393/5 "2018-10-17T10:51:08Z")

</div>

Thanks, varinfo() was so useful
