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

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 :pray:), 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 is running, but then drops back to zero once its done.

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 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)

If you want to see the full Dockerfile as an example its here, including how to tweak the IJulia kernel to use the sysimage.