julia
julia copied to clipboard
RFC: Avoid running out of memory by checking available memory before allocating
This improves the user experience when running with a memory constraint, e.g. in a container, where malloc wouldn't fail but instead the OOM killer would terminate the process (which people have been frequently complaining about). https://github.com/JuliaLang/julia/pull/46796 improves the situation by using appropriate GC heuristics, but this PR would make it mostly impossible to overallocate.
RFC because:
- too expensive: even though I assume these code paths are only executed for large allocations, adding ~10us is unacceptable
- it's not waterproof, as allocations may come from external libraries
- it makes it impossible to overcommit memory
Could we put this behind a command line flag?