# OutOfMemoryError() instead of allocating too much resources in the job scheduler

**URL:** https://discourse.julialang.org/t/outofmemoryerror-instead-of-allocating-too-much-resources-in-the-job-scheduler/45575
**Category:** General Usage
**Created:** [August 26, 2020, 1:15pm UTC](https://discourse.julialang.org/t/outofmemoryerror-instead-of-allocating-too-much-resources-in-the-job-scheduler/45575 "2020-08-26T13:15:23Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)
#### Post date: [August 26, 2020, 1:35pm UTC](https://discourse.julialang.org/t/outofmemoryerror-instead-of-allocating-too-much-resources-in-the-job-scheduler/45575/2 "2020-08-26T13:35:22Z")

</div>

I do this as I described in an old post [here](https://discourse.julialang.org/t/stopping-code-if-a-given-ram-limit-is-reached/18593/9). In addition just add something like

```julia
# MEMORY CONSUMPTION TEST
function memOK( mb::Int, memlimit::Int )
    if( mb > memlimit )
        println("### Memory-usage too high: $mb (MB)")
        return false
    else
        return true
    end
end

```

and terminate your program if the latter function returns `false`.

---

_[View the full topic](https://discourse.julialang.org/t/outofmemoryerror-instead-of-allocating-too-much-resources-in-the-job-scheduler/45575)._
