Mathematica 9 is now available

MemoryConstrained

Usage

MemoryConstrained[expr, b]用于对expr进行计算,如果该计算需要超过b字节的内存,它就停止.
• 如果内存不够,MemoryConstrained[expr, b, failexpr] 返回 failexpr.


Notes

• 如果在对expr进行计算的过程中所请求的附加内存量超过b字节,MemoryConstrained会产生一个中断来结束对expr的计算.
• 只用当该计算被异常中止时,MemoryConstrained 才对failexpr进行计算.
• 如果该计算被异常中止,而没有failexpr被指定,MemoryConstrained返回$Aborted.
MemoryConstrained所产生的异常中止可以被当作由Abort产生的异常中止处理,因而能被AbortProtect所控制.
• 参见Mathematica 全书: 2.13.4节.
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.