Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB "out of memory" error

Tags:

matlab

When I run a sample script in MATLAB, it says:

Out of memory. Type HELP MEMORY for your options.

When I type "memory", it reports:

Maximum possible array:             156 MB (1.638e+008 bytes) *
Memory available for all arrays:    740 MB (7.756e+008 bytes) **
Memory used by MATLAB:             1054 MB (1.105e+009 bytes)
Physical Memory (RAM):             3070 MB (3.219e+009 bytes)

*  Limited by contiguous virtual address space available.
** Limited by virtual address space available.

Is there any way to get around this error? I'm using Windows XP x32 with MATLAB 2009a.

like image 218
Contango Avatar asked Aug 14 '09 11:08

Contango


People also ask

How do I clear memory in MATLAB?

To clear all variables from the current workspace, use clear or clearvars . To clear all global variables, use clear global or clearvars –global . To clear a particular class, use clear myClass . To clear a particular function or script, use clear functionName .


2 Answers

I faced a similar error while running an (old) C file in MATLAB using mex.

I found my solution at this issue on GitLab.

First, uncheck the option "Limit the maximum Array Size to a % of RAM" located under Preferences -> Workspace, as also indicated in this earlier answer.

Once applied, run your C file in the command window using

mex filename.c -compatibleArrayDims
like image 163
VIREN RAMCHANDANI Avatar answered Sep 23 '22 17:09

VIREN RAMCHANDANI


pack does a memory defragmentation. It might help you a bit as far as the contiguous memory available.

like image 32
Marcin Avatar answered Sep 21 '22 17:09

Marcin