Killed VS OutOfMemoryError()

Why we have two different error messages? What is the difference between Killed and OutOfMemoryError() messages?

julia> A = fill(2, 5000000000)
ERROR: OutOfMemoryError()

slightly lower:
julia> A = fill(2, 4000000000)
Killed

I saw above example in this post How to track total memory usage of Julia process over time - #15 by Palli. What is the purpose of having two different messages for memory shortage?

There aren’t two different messages in Julia, it’s only one:

  • OutOfMemoryError() is a Julia error which indicates that you tried to allocate an object which Julia was able to determine would use too much memory, and it prevented you from doing it
  • Killed is a message from your operating system to inform you that it terminated the Julia process.
4 Likes

There is a 3rd option when neither Julia nor the operating system notices you overdid it on memory allocation and stops you in time: the entire machine freezes or shuts down.