MATLAB: Out of memory ?? help needed

out of memory

I have a laptop which has a 8G of ram memory.
however, when I run a matlab, it says I am out of memory.
I only run matlab only, and closed all other unnecessary windows.
I am pretty sure I have a sufficient memory to run the matlab program.. but yeah this happend..
Any suggestion or solution for this issue?
I already tried following stuff..
1- Give higher priority to Matlab.exe task. You can do that by going to task manager, Processes tab, right click the Matlab.exe Task, select priority and set it to higher priority (say real time), this tells Windows to allocate more resources to this process.
2- Increase the page file size of your applications in general. 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.
3- While in 2 at Performance, make sure that the it is set for "Programs" and not for "Background services". "Programs" should be the default.
4- Also make sure while doing step 2 that the >Visual effects tab of "performance options" is set to "Adjust for best performance" . This will remove lots of animation, shades, fades and and other visual effects from your screen (the next time you re-boot) but free some memory for the applications including the MATLAB. I used this trick with my older laptop which was 32 bits OS and used to have a profound impact on applications performance.

Best Answer

On a 32 bit OS with 32 bit matlab, matlab can only 2GB (3GB with some special settings) regardless of how much memory you have on your computer.
None of the changes you've made would make any significant difference, and to be honest you're better off restoring things to their default settings. Increasing Java heap memory won't help either, if anything by doing that you may reduce the memory available for array allocation.
Your only option is to reduce the memory requirements of your code. Do you need to have all the images in memory at the same time? Maybe you can process them one at a time. If not, you'll have to use a different data type for your images. If you can use uint8 instead of double, that's already reducing the memory needed by a factor of 8.
It's hard to tell you what to do without more details. At the command line, write
dbstop if error
and provide the output of
memory
and
whos
when the code fails.