Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When evaluating MemoryConstrained for a large memory limit:

MemoryConstrained[Print["aaa"],10^10]

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.

share|improve this question
    
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? –  Szabolcs Mar 12 at 19:32
    
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. –  Szabolcs Mar 12 at 19:35
    
I am using Mathematica 9.0.1 and 32-bit Windows 7. –  Giovanni Mar 12 at 19:45

1 Answer 1

up vote 4 down vote accepted

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).

share|improve this answer
    
Ok, I tested the code on the computer I want to run the script and It worked. It is 64 bits. Thank you. –  Giovanni Mar 12 at 19:56
    
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. –  Giovanni Mar 12 at 20:15
    
@Giovanni $SystemWordLength tells you if this version of Mathematica is 32 or 64 bit. –  Szabolcs Mar 12 at 20:15
    
Hmm nice! I will use that instead. –  Giovanni Mar 12 at 20:17
    
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. :) –  Giovanni Mar 12 at 20:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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