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

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?

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.

2 Likes