# Is there a way cap memory usage to keep MyBinder from crashing?

**URL:** <https://discourse.julialang.org/t/is-there-a-way-cap-memory-usage-to-keep-mybinder-from-crashing/32325>\
**Category:** General Usage\
**Created:** [December 16, 2019, 10:18am UTC](https://discourse.julialang.org/t/is-there-a-way-cap-memory-usage-to-keep-mybinder-from-crashing/32325 "2019-12-16T10:18:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [December 16, 2019, 10:18am UTC](https://discourse.julialang.org/t/is-there-a-way-cap-memory-usage-to-keep-mybinder-from-crashing/32325/1 "2019-12-16T10:18:59Z")

</div>

MyBinder has a 2GB memory cap. I have a package which used to load fine on there, but recent compiler improvements in 1.3, which although they improve speed (thank you devs 🙏), it comes at the cost of more memory usage, which is causing this to no longer work on MyBinder. I’m wondering if there’s anything I can do, even which might sacrifice loading speed, which might make it work on there anyway?

FWIW, the memory profile of loading this package is that it grows about 3GB while running [`using CMBLensing`](https://github.com/marius311/CMBLensing.jl) is running, but then drops back to zero once its done.  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/0/303ec0d115edecc1be9a7506a8e52687513ce6f9.png)

---

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [February 10, 2020, 7:14pm UTC](https://discourse.julialang.org/t/is-there-a-way-cap-memory-usage-to-keep-mybinder-from-crashing/32325/2 "2020-02-10T19:14:59Z")

</div>

I ended up solving the underying issue so figure I’d report here on the off chance anyone else is looking for a solution.

What I did was use [PackageCompilerX](https://github.com/JuliaComputing/PackageCompilerX.jl) to precompile my package. This removes that big memory spike when loading the package, and it now fits within the Binder limit.

If you do this, note that you may want to compile with `create_sysimage(..., cpu_target="generic")` otherwise the built image may not be compatible (this was suggested [here](https://github.com/JuliaComputing/PackageCompilerX.jl/issues/106))

If you want to see the full Dockerfile as an example its [here](https://github.com/marius311/CMBLensing.jl/blob/847bb4596ccebdda5f76938a5823b08dfae7be6b/Dockerfile.base), including how to tweak the IJulia kernel to use the sysimage.
