evaluates expr, stopping if more than b bytes of memory are requested.
returns failexpr if the memory constraint is not met.
- MemoryConstrained generates an interrupt to stop the evaluation of expr if the amount of additional memory requested during the evaluation of expr exceeds b bytes.
- MemoryConstrained evaluates failexpr only if the evaluation is aborted.
- MemoryConstrained returns $Aborted if the evaluation is aborted and no failexpr is specified.
- Aborts generated by MemoryConstrained are treated just like those generated by Abort, and can thus be overruled by AbortProtect.
- MemoryConstrained[expr,Infinity] imposes no memory constraint.
Basic Examples (2)
The loop ran until memory allocation for the result of Range exceeded the limit:
Wolfram Research (1988), MemoryConstrained, Wolfram Language function, https://reference.wolfram.com/language/ref/MemoryConstrained.html (updated 2007).
Wolfram Language. 1988. "MemoryConstrained." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/MemoryConstrained.html.
Wolfram Language. (1988). MemoryConstrained. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MemoryConstrained.html