# Heap-size-hint usage recommendations

**URL:** <https://discourse.julialang.org/t/heap-size-hint-usage-recommendations/98697>\
**Category:** Tooling\
**Tags:** ci, docker, garbage-collection\
**Created:** [May 11, 2023, 5:35pm UTC](https://discourse.julialang.org/t/heap-size-hint-usage-recommendations/98697 "2023-05-11T17:35:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rssdev10](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@rssdev10](https://discourse.julialang.org/u/rssdev10)\
**Post date:** [May 11, 2023, 5:35pm UTC](https://discourse.julialang.org/t/heap-size-hint-usage-recommendations/98697/1 "2023-05-11T17:35:31Z")

</div>

Julia 1.9 got a new CLI option `--heap-size-hint`. [See #45369 for details](https://github.com/JuliaLang/julia/pull/45369#issuecomment-1544204022) and [Julia execution inside a container with restricted RAM](https://discourse.julialang.org/t/julia-execution-inside-a-container-with-restricted-ram/81173)

This option allows to set a soft limit of memory consumption when the garbage collector should start an intensive work. We can expect this value should be in between 50-80% of RAM available for the Julia-based application. For intensive query server applications, this value may be less than 50% and should be adjusted based on experimentation with the appropriate load.

I’m starting this topic to collect together receipts of usage of this option for exact environments like GitHub Actions, Docker, Helm, Terraform, etc. Please share your ideas and code.

---

<div class="post-metadata">

**Author:** ![rssdev10](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@rssdev10](https://discourse.julialang.org/u/rssdev10)\
**Post date:** [May 13, 2023, 3:46pm UTC](https://discourse.julialang.org/t/heap-size-hint-usage-recommendations/98697/2 "2023-05-13T15:46:42Z")

</div>

Linux. Calculate the value based on free memory:

```julia
julia --project=. --threads=auto --startup-file=no --heap-size-hint=`grep MemFree /proc/meminfo | awk '{print int($2 * 0.8) "k"}'`...

```

---

<div class="post-metadata">

**Author:** ![xgdgsc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xgdgsc/32/608_2.png) [@xgdgsc](https://discourse.julialang.org/u/xgdgsc)\
**Post date:** [May 26, 2023, 8:56am UTC](https://discourse.julialang.org/t/heap-size-hint-usage-recommendations/98697/3 "2023-05-26T08:56:14Z")

</div>

Available memory make more sense to my work. So it’ s

```julia
julia --heap-size-hint=`grep MemAvailable /proc/meminfo | awk '{print int($2 * 0.3) "k"}'`

```

for me.

---

<div class="post-metadata">

**Author:** ![rssdev10](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@rssdev10](https://discourse.julialang.org/u/rssdev10)\
**Post date:** [May 30, 2023, 3:20am UTC](https://discourse.julialang.org/t/heap-size-hint-usage-recommendations/98697/4 "2023-05-30T03:20:55Z")

</div>

> [@xgdgsc](#):
>
> `MemAvailable`

Percent of `MemAvailable` only is not a good metric. The problem is that 1GB of available RAM is not the same as 8GB because in the first case the operating system uses half of it for it’s own purposes. In the second case, most of the RAM will be available. `MemFree` may be more reliable metric if the Julia application is running in a Docker-container and nothing memory consumptive was running before. The percent of `MemFree` might be hard coded inside the Dockerfile, but `MemAvailable` depends on a VM configurations outside the Dockerfile.

Note that the low value of `--heap-size-hint` forces GC to do excessive memory scans and eats CPU.
