# Understanding memory usage in Julia

**URL:** <https://discourse.julialang.org/t/understanding-memory-usage-in-julia/101647>\
**Category:** Performance\
**Tags:** memory, memory-allocation\
**Created:** [July 15, 2023, 8:20am UTC](https://discourse.julialang.org/t/understanding-memory-usage-in-julia/101647 "2023-07-15T08:20:00Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![Andrea\_Vigliotti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_vigliotti/32/7635_2.png) [@Andrea\_Vigliotti](https://discourse.julialang.org/u/Andrea_Vigliotti)\
**Post date:** [July 16, 2023, 7:12am UTC](https://discourse.julialang.org/t/understanding-memory-usage-in-julia/101647/19 "2023-07-16T07:12:09Z")

</div>

> [@sgaure](#):
>
> Is your Julia program parallel, i.e. with two tasks (via @spawn or @threads)?

yes, the code is parallel and uses `@threads` in a `for` loop for assembling the global stiffness matrix from the elemental stiffness matrices, but no memory is allocated within the `for` loop, all the required arrays are allocated in advance. I will try to remove that and report what happens.

> [@danielwe](#):
>
> From the original post, it sounds like this is what OP is doing (“I also store the cholesky factorization for re-use”), but this is not what’s happening in the example code provided later.

what I meant by re-using is that the same factorization is used for a few different problems before a new stiffness matrix is assembled and factorized. That is because the cost for factorization is the highest and it makes sense to keep using the same factorized matrix at the cost of taking more iterations rather than assembling and factorizing at each step (that would take one iteration only)

reusing the factorization in the sense you showed in your post proved not to be effective in my case

---

_[View the full topic](https://discourse.julialang.org/t/understanding-memory-usage-in-julia/101647)._
