# Is there a way to limit memory as reported by Sys.total\_memory()?

**URL:** <https://discourse.julialang.org/t/is-there-a-way-to-limit-memory-as-reported-by-sys-total-memory/93909>\
**Category:** General Usage\
**Tags:** memory\
**Created:** [February 2, 2023, 8:24am UTC](https://discourse.julialang.org/t/is-there-a-way-to-limit-memory-as-reported-by-sys-total-memory/93909 "2023-02-02T08:24:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![evanderveer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evanderveer/32/37519_2.png) [@evanderveer](https://discourse.julialang.org/u/evanderveer)\
**Post date:** [February 2, 2023, 8:24am UTC](https://discourse.julialang.org/t/is-there-a-way-to-limit-memory-as-reported-by-sys-total-memory/93909/1 "2023-02-02T08:24:21Z")

</div>

I am trying to run my Julia code on a computing cluster running SLURM. It runs just fine on my own pc, but whenever I try to run it on the cluster (even when I give it the same amount of total memory), my job gets canceled because it uses too much memory. I am thinking the reason is that julia thinks it has access to all of the memory on the compute node (Sys.total\_memory() always shows the total memory of the node, not the amount I assign to the job). As a result, it runs GC too infrequently. Is there a way to tell julia how much memory it has access to?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [February 2, 2023, 9:05am UTC](https://discourse.julialang.org/t/is-there-a-way-to-limit-memory-as-reported-by-sys-total-memory/93909/2 "2023-02-02T09:05:20Z")

</div>

With julia v1.9 you can try setting `--heap-size-hint=<size>`: [julia/HISTORY.md at e48a0c99bef949a84979c05dc33fd5578f684c1d · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/e48a0c99bef949a84979c05dc33fd5578f684c1d/HISTORY.md#command-line-option-changes). This isn’t exactly the same as what you asked, but it should help the garbage collector to work more eagerly than what it’d do by default.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [February 2, 2023, 9:29am UTC](https://discourse.julialang.org/t/is-there-a-way-to-limit-memory-as-reported-by-sys-total-memory/93909/3 "2023-02-02T09:29:32Z")

</div>

What version of julia are you using? I seem to remember that there were some changes somewhat recently about how we query the memory.
