# Is my understanding of Julia correct?

**URL:** <https://discourse.julialang.org/t/is-my-understanding-of-julia-correct/76924>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [February 22, 2022, 5:29pm UTC](https://discourse.julialang.org/t/is-my-understanding-of-julia-correct/76924 "2022-02-22T17:29:50Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [February 22, 2022, 7:48pm UTC](https://discourse.julialang.org/t/is-my-understanding-of-julia-correct/76924/7 "2022-02-22T19:48:24Z")

</div>

> [@sychen52](#):
>
> ### Heap or Stack
> 
> As a high level language, Julia also does not allow the programmer to explicitly control whether the memory should be allocated on stack or heap. Instead, it is up to the complier to optimize for you.

This one could use a bit of a caveat, in that _typically_ mutable structs are heap allocated and _typically_ immutable structs are stack allocated, but the compiler is free to optimize things either way or even remove them entirely (if it can do so unobservably). See, e.g., [A nice explanation of memory stack vs. heap - #2 by sylvaticus](https://discourse.julialang.org/t/a-nice-explanation-of-memory-stack-vs-heap/53915/2) and the subsequent posts.

---

_[View the full topic](https://discourse.julialang.org/t/is-my-understanding-of-julia-correct/76924)._
