# Not understanding linear growing allocations

**URL:** <https://discourse.julialang.org/t/not-understanding-linear-growing-allocations/71734>\
**Category:** Performance\
**Created:** [November 18, 2021, 5:17pm UTC](https://discourse.julialang.org/t/not-understanding-linear-growing-allocations/71734 "2021-11-18T17:17:19Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [November 18, 2021, 11:24pm UTC](https://discourse.julialang.org/t/not-understanding-linear-growing-allocations/71734/21 "2021-11-18T23:24:56Z")

</div>

My personal didactic explanation of how that is the way it is: [Scope of loops · JuliaNotes.jl](https://m3g.github.io/JuliaNotes.jl/stable/loopscopes/)

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [November 18, 2021, 11:27pm UTC](https://discourse.julialang.org/t/not-understanding-linear-growing-allocations/71734/22 "2021-11-18T23:27:27Z")

</div>

> [@goerch](#):
>
> simply sounds stupid too me

You can go read some of the threads on this topic. They are numerous and heated. You may be able to see why it ended up with a compromise.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [November 18, 2021, 11:29pm UTC](https://discourse.julialang.org/t/not-understanding-linear-growing-allocations/71734/23 "2021-11-18T23:29:26Z")

</div>

The one reason for that difference is: interactive vs. non-interactive usage.

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [November 18, 2021, 11:42pm UTC](https://discourse.julialang.org/t/not-understanding-linear-growing-allocations/71734/24 "2021-11-18T23:42:07Z")

</div>

OK, I accept the compromise and am waiting for the fallout. So what linter should we concentrate on?

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [November 18, 2021, 11:47pm UTC](https://discourse.julialang.org/t/not-understanding-linear-growing-allocations/71734/25 "2021-11-18T23:47:50Z")

</div>

I think that it would be great to have a “performance tips” linter/package, to which new users in particular should be directed from the top of the tips page.

That said, after a while writing Julia these non-constant global assignments become like carbons with five covalent bonds, one simply get uncomfortable just at starring at them.

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [November 19, 2021, 12:25am UTC](https://discourse.julialang.org/t/not-understanding-linear-growing-allocations/71734/26 "2021-11-19T00:25:13Z")

</div>

Very nice write-up Leandro. Quote: “nobody writes critical code directly to the REPL” probably should be something like a motto, to encourage beginners not to write critical code directly to the REPL. I still often dump code into the REPL when I should know better…

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [November 19, 2021, 12:31am UTC](https://discourse.julialang.org/t/not-understanding-linear-growing-allocations/71734/27 "2021-11-19T00:31:11Z")

</div>

Yes, it is very common to fall into this problem when benchmarking a piece of code which may be critical in a larger context. The compromise of the scopes allow we to copy and paste the code to the REPL and causes this possible benchmarking artifact. But the real code, written in a function, in a separate file, won’t be type unstable without warning. That is more about training how to properly benchmark things than actually a scoping problem. Benchmarking is tricky many times, not only because of this.

---

<div class="post-metadata">

**Author:** ![sashmit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sashmit/32/18791_2.png) [@sashmit](https://discourse.julialang.org/u/sashmit)\
**Post date:** [November 22, 2021, 4:35am UTC](https://discourse.julialang.org/t/not-understanding-linear-growing-allocations/71734/28 "2021-11-22T04:35:07Z")

</div>

Well, it’s good that the most recent version of vscode-julia can accept output from linters, I felt like that was one thing that was missing from the juno → vscode move.

Personally, I would love to see something like Rust’s clippy, which given Rust’s complexity, helps its overall developer experience tremendously:  
[https://github.com/rust-lang/rust-clippy](https://github.com/rust-lang/rust-clippy)

[Previous page](https://discourse.julialang.org/t/not-understanding-linear-growing-allocations/71734.md?page=1)
