# Reducing usage of resources during precompilation

**URL:** <https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903>\
**Category:** General Usage\
**Tags:** memory-allocation, precompilation, binder\
**Created:** [February 8, 2024, 12:50am UTC](https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903 "2024-02-08T00:50:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![pvarshinee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pvarshinee/32/206855_2.png) [@pvarshinee](https://discourse.julialang.org/u/pvarshinee)\
**Post date:** [February 8, 2024, 12:50am UTC](https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903/1 "2024-02-08T00:50:56Z")

</div>

Hello, I am trying to set up a Julia kernel in [mybinder.org](http://mybinder.org) with a few packages. [Here](https://github.com/priyaasrini/AlgJulia-Book-Binder2) is the GitHub repo for the kernel. I find the precompilation failing due to the process overrunning the maximum amount of RAM (2GB) provided by the Binder.

How can I reduce the usage of memory during the precompilation process?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [February 8, 2024, 1:12am UTC](https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903/2 "2024-02-08T01:12:34Z")

</div>

2GB is ridiculously little. I doubt that mybinder container could be useful with so little memory. Get a bit more, perhaps?

---

<div class="post-metadata">

**Author:** ![Tortar](https://avatars.discourse-cdn.com/v4/letter/t/6bbea6/32.png) [@Tortar](https://discourse.julialang.org/u/Tortar)\
**Post date:** [February 8, 2024, 1:19am UTC](https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903/3 "2024-02-08T01:19:40Z")

</div>

I’m not sure but maybe this flag

```julia
 --heap-size-hint=<size> Forces garbage collection if memory usage is higher than that value.
                            The memory hint might be specified in megabytes(500M) or gigabytes(1G)

```

when starting Julia can help?

---

<div class="post-metadata">

**Author:** ![pvarshinee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pvarshinee/32/206855_2.png) [@pvarshinee](https://discourse.julialang.org/u/pvarshinee)\
**Post date:** [February 8, 2024, 5:36pm UTC](https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903/4 "2024-02-08T17:36:18Z")

</div>

Thanks a lot! May I please know how much memory would be recommended?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [February 8, 2024, 5:37pm UTC](https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903/5 "2024-02-08T17:37:38Z")

</div>

I find that 8GB is a decent lower bound.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [February 8, 2024, 5:48pm UTC](https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903/6 "2024-02-08T17:48:20Z")

</div>

On Linux you can use zram to get 50% more RAM for free… And you can always use a swap file if you are patient…

---

<div class="post-metadata">

**Author:** ![pvarshinee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pvarshinee/32/206855_2.png) [@pvarshinee](https://discourse.julialang.org/u/pvarshinee)\
**Post date:** [February 8, 2024, 6:01pm UTC](https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903/7 "2024-02-08T18:01:04Z")

</div>

I would try requesting mybinder for memory limit increase, but I am doubtful they will support it. What would be the recommended alternative? A private BinderHub deployment?

@ufechner7 Since mybinder is a public cloud service, I am not sure if I can fiddle with the configuration myself. I will give @Tortar’s solution a try!

---

<div class="post-metadata">

**Author:** ![pvarshinee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pvarshinee/32/206855_2.png) [@pvarshinee](https://discourse.julialang.org/u/pvarshinee)\
**Post date:** [February 10, 2024, 2:09am UTC](https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903/8 "2024-02-10T02:09:59Z")

</div>

I eventually made up a postBuild file for binder to precompile the required packages with “heap-size-hint=1G” , and made a minimal Julia environment to begin with! This seems to help! Thanks everyone !

---

<div class="post-metadata">

**Author:** ![BVPs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bvps/32/2190_2.png) [@BVPs](https://discourse.julialang.org/u/BVPs)\
**Post date:** [October 6, 2024, 12:14am UTC](https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903/9 "2024-10-06T00:14:58Z")

</div>

@pvarshinee, I would greatly appreciate it if you could show me how to generate a postBuild file for binder to precompile packages. Thanks a lot!

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [October 6, 2024, 2:14am UTC](https://discourse.julialang.org/t/reducing-usage-of-resources-during-precompilation/109903/10 "2024-10-06T02:14:00Z")

</div>

A possible solution specific to precompilation is this enviroment variable: [`JULIA_NUM_PRECOMPILE_TASKS`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_NUM_PRECOMPILE_TASKS).
