Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB not throwing OutOfMemoryExceptions or Maximum variable size errors

In a previous version of MATLAB (7.6), I used to get OutOfMemoryErrors that I thought were kind of annoying. But since I upgraded to 7.11, for some reason it's not throwing the errors anymore.

This means that when I accidentally try to make a variable that's way too large, the MATLAB shell will try to create the variable and bring my machine to a halt.

I'd really like to have these errors get thrown, so that I can exit out gracefully or debug my code, but I can't find the solution anywhere.

Possibly useful details: I'm using OSX 10.5 on a 64-bit machine, with 4GB of RAM.

In MATLAB 7.6:

$ rand(50000);
??? Error using ==> rand
Maximum variable size allowed by the program is exceeded.

In MATLAB 7.11:

$ rand(50000);
(hang)
like image 743
Austin A. Avatar asked Feb 16 '11 23:02

Austin A.


People also ask

How do you increase the maximum size of an array in MATLAB?

Accepted Answer 1. Go to MATLAB > Preferences > Workspace and ensure the Maximum array size limit is set to 100%. Then execute 'memory' command in the Command Window and send the output. Ensure that the Maximum possible array size is larger than the memory required by the data.

How do I give more RAM to MATLAB?

You can do this by right clicking MyComputer ->properties->Advanced System Settings ->Advanced-> Performance->Virtual Memory (change..). Then the tick from the Automatic .... and set the initial and maximum page size to say 10000 MB.


2 Answers

Between version 7.6 and 7.11 the Macintosh version of MATLAB switched from a 32-bit application to a 64-bit application. So now instead of running out of address space MATLAB thrashes.

like image 111
SCFrench Avatar answered Sep 22 '22 22:09

SCFrench


Matlab doesn't hang. It's just paging, which takes forever. Try assigning a large array, open the Activity Monitor, and see the 'Virtual Memory' grow and grow.

If you reduce the page file size on your system, you can avoid that issue.

like image 37
Jonas Avatar answered Sep 20 '22 22:09

Jonas