2 ms·
Allocate 1MB of memory upfront. When OOM happens, free that memory and run recovery mechanism. No OOM recovery is fool proof. What if the OOM situation is cau
by nuclear_eclipse 17y ago
Allocate 1MB of memory upfront. When OOM happens, free that memory and run recovery mechanism.
No OOM recovery is fool proof. What if the OOM situation is caused by another process constantly consuming memory? As soon as you free your 1MB overhead, the other process could immediately consume it and again you're in an OOM state.
Granted, the likelyhood of this is slim, but then again, so is an OOM situation period. In the world of virtual memory and swap space, it pretty much takes a rogue process to trigger an OOM error in the first place.
- vlisivka 17y agoOlder JVM's behave in such way: in the OOM situation they runs Garbage Collection process to reclaim some unused memory. GC itself requires some memory to operate, so JVM reserves some memory to GC.