Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Memory Usage  /
MemoryConstrained

  • MemoryConstrained[ expr , b ] evaluates expr, stopping if more than b bytes of memory are requested.
  • MemoryConstrained[ expr , b , failexpr ] 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.
  • See the Mathematica book: Section 2.13.4.
  • See also: TimeConstrained, MaxMemoryUsed, $RecursionLimit, Abort.

    Further Examples

    Here is an expression that would take a lot of memory to evaluate. The constraint stops the computation and returns the string.

    In[1]:=

    Out[1]=



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.