When evaluating MemoryConstrained for a large memory limit:


I get:

MemoryConstrained::ipnfm: Positive machine-sized integer or Infinity expected at position 2 in MemoryConstrained[Print[aaa],10^10]. >>

I have tested to find the limit, and is exactly 4294967295 bytes. Is there a reason for this? I need a larger memory limit.

I am using Mathematica 9.0.1 and 32-bit Windows 7.

  • $\begingroup$ I cannot reproduce this problem with the OS X version of Mathematica 8.0.4 or 9.0.1. (Both are 64-bit versions.) What OS are you using and what version of Mathematica? Also, is it a 32-bit or a 64-bit version? $\endgroup$
    – Szabolcs
    Mar 12, 2014 at 19:32
  • $\begingroup$ 32-bit programs simply can't use more memory than this limit (more typically: half this limit). I also can't reproduce the problem with a 64-bit Mathematica 9 on Windows. $\endgroup$
    – Szabolcs
    Mar 12, 2014 at 19:35
  • $\begingroup$ I am using Mathematica 9.0.1 and 32-bit Windows 7. $\endgroup$ Mar 12, 2014 at 19:45

1 Answer 1


This is not a specific limitation of Mathematica, but a limitation of 32-bit addressing and your 32-bit operating system. 64-bit versions of Mathematica do accept higher limits in MemoryConstrained.

What "32-bit" means is precisely that memory is indexed with integers stored on 32-bits, i.e. at most 2^32 = 4294967296 bytes can be addressed. A program running in 32-bit mode simply cannot use more than this much memory, i.e. 4 GB. In practice, the limit is more typically 2 GB.

Even if your computer has more than 4 GB of memory, if you use a 32-bit operating system, it can't take advantage of more than 4 GB (and in the case of Windows single programs will typically be able to use no more than 2 GB).

  • $\begingroup$ Ok, I tested the code on the computer I want to run the script and It worked. It is 64 bits. Thank you. $\endgroup$ Mar 12, 2014 at 19:56
  • $\begingroup$ To run on both systems: MemoryLimit[]:=If[StringMatchQ[$System,"64-bit"],8*1024^3,1024^3]. 8 GB on the node and 1 GB on my computer. $\endgroup$ Mar 12, 2014 at 20:15
  • $\begingroup$ @Giovanni $SystemWordLength tells you if this version of Mathematica is 32 or 64 bit. $\endgroup$
    – Szabolcs
    Mar 12, 2014 at 20:15
  • $\begingroup$ Hmm nice! I will use that instead. $\endgroup$ Mar 12, 2014 at 20:17
  • $\begingroup$ When I posted the code above it left out the * from 64-bit. That will not work. Maybe you can just include that code (or the better version with $SystemWordLength) as a sidenote in your answer for others who may need. :) $\endgroup$ Mar 12, 2014 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.