# What happens to a view when the parent array is reassigned?

**URL:** https://discourse.julialang.org/t/what-happens-to-a-view-when-the-parent-array-is-reassigned/101487
**Category:** New to Julia
**Tags:** question, array, views
**Created:** [July 11, 2023, 3:11pm UTC](https://discourse.julialang.org/t/what-happens-to-a-view-when-the-parent-array-is-reassigned/101487 "2023-07-11T15:11:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jad\_Zeitouni](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jad_zeitouni/32/50678_2.png) [@Jad\_Zeitouni](https://discourse.julialang.org/u/Jad_Zeitouni)
#### Post date: [July 11, 2023, 3:11pm UTC](https://discourse.julialang.org/t/what-happens-to-a-view-when-the-parent-array-is-reassigned/101487/1 "2023-07-11T15:11:58Z")

</div>

Let’s say I have an array x and a create a view y. I then reassign x to another array at some point. I can see that y still points to the original array, so that I don’t actually clear memory by reassigning x. Is the only way to clear the memory to reassign y (and any other views of x) as well?

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [July 11, 2023, 4:11pm UTC](https://discourse.julialang.org/t/what-happens-to-a-view-when-the-parent-array-is-reassigned/101487/2 "2023-07-11T16:11:29Z")

</div>

Julia has a garbage collector, the memory will be freed at some point when there is no reference to it anymore. If the view `y` was the last thing that kept a reference to array `x`, then reassigning `y` will make that `x` is free to be collected in the future.
