Defining exception handlers for AlmostOutOfMemory or AlmostOutOfMemoryError allows you to catch conditions in which your Gem would otherwise run out of temporary object memory and exit, and perform some actions to make more memory available.
However, if the operation that requires more memory than is currently available occurs when the code is executing in a primitive call, the AlmostOutOfMemory handlers cannot intercept the exception and take action to avoid an exit with out of memory.
Avoid executing single primitive operations that will require significant amounts of memory; breaking these up will return control to where the AlmostOutOfMemory handler can free up memory.
Last updated: 8/9/24