# Basic question about memory allocation

**URL:** <https://discourse.julialang.org/t/basic-question-about-memory-allocation/59791>\
**Category:** New to Julia\
**Created:** [April 22, 2021, 10:01am UTC](https://discourse.julialang.org/t/basic-question-about-memory-allocation/59791 "2021-04-22T10:01:51Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![pg261](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pg261/32/24270_2.png) [@pg261](https://discourse.julialang.org/u/pg261)\
**Post date:** [April 22, 2021, 12:14pm UTC](https://discourse.julialang.org/t/basic-question-about-memory-allocation/59791/7 "2021-04-22T12:14:24Z")

</div>

Thanks for bearing with me 🙂

Well, [here](http://irma.math.unistra.fr/~guillot/foo.html) is an example of an implementation of chained lists (as an exercise!), where everything is immutable, in a Pluto notebook. And [here](http://irma.math.unistra.fr/~guillot/bar.html) is a version with mutable structs, in a Jupyter notebook.

In the immutable version, I _think_ that if L is a chained list and I go `NonEmplyList(a, L)` (or `a --> L`), to add an element at the beginning of the list, then `L` gets copied. I’d like to know whether this is the case, and more importantly, I’d like to know why, and how I could have predicted the behaviour.

If the answer is “it depends”, then well, I’m uncomfortable.

---

_[View the full topic](https://discourse.julialang.org/t/basic-question-about-memory-allocation/59791)._
