out of memory ?? help needed

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.

5 Comments

To be clear, it is the act of launching the MATLAB application itself that causes the problem and the "out of memory" message is from Windows? It does not result from running a program within MATLAB?
Also please specify if the OS is 32 or 64 bit and if matlab is 32 or 64 bit. Typing computer in matlab will give you the answer to that last one.
What does memory and whos say when you get the error?
I got an error from when I try to run a code. The code extract data from several images, about 200. When I extract 50 files at once, it wordk well. But when I try over 50, it starts to give me an error message.
My os is 32bit and matlab is also 32 bit.
How large are the images, and how much data do you extract from each?
Go to Home -> Preference icon -> Workspace" : Uncheck the 'Limit the maximum array size to a percentage of RAM

Sign in to comment.

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

4 Comments

Maximum possible array: 434 MB (4.546e+08 bytes) *
Memory available for all arrays: 765 MB (8.024e+08 bytes) **
Memory used by MATLAB: 434 MB (4.546e+08 bytes)
Physical Memory (RAM): 2732 MB (2.864e+09 bytes)
Name Size Bytes Class Attributes
A1 1x1 2368254 struct
back_files 100x1 37620 struct
back_path 1x48 96 char
n_back 1x1 8 double
n_im 1x1 8 double
this is what I get when I type memory and whos after code fails. So by looking at your comment, the only way is to have 62 bit for both window and matlab.... :(
Despite your statement that your laptop has 8GB of memory, according to matlab (and most likely the OS) it only appear to have a little under 3GB.
Of those 3GB, only a little over 1GB (765MB free + 434MB used) appear to be available for Matlab. That's not much. You could try to increase that by closing other running programs (CTRL + SHIFT + ESC to bring up the task manager that will show you the memory used by all processes).
I was hoping that whos would show us the size and type of your images, but they would appear to be stored within the structure A1. Could you tell us what they are?
Yes switching to 64bit windows and matlab would let you use all the memory available on your computer.
I re installed my os, and now i can use upto 8g. and I can run matlab without any problem!!
Thanks!
YJ what you did for use all your memory on matlab? I have the same problem that you had but the difference is that i already have 64 bits in matlab and windows. The problem is that i don't know how to alocate more memory for use in matlab. Can you help me?

Sign in to comment.

More Answers (4)

I solved the problem, and it works well, you can follow these steps.
- Go to Home -> Preference icon -> General -> Java Heap Memory -> Allocate what size of memory you want
- In Preference window, go to "Workspace" (out of Java heap memory level) -> See "Matlab Array size limit"
Make sure uncheck the 'Limit the maximum array size to a percentage of RAM'. Because you want to extend memory
so we don't need this feature.
- Done.
Julia
Julia on 3 Sep 2014
Hi,
I once got an out-of-memory error while using a feature of the report generator.
I solved it by allocating more java heap memory to Matlab:
Preferences (in the Matlab tab "Home") --> General --> Java Heap Memory

1 Comment

I tried this one as well.. but did not work :(

Sign in to comment.

Mohsin Ali
Mohsin Ali on 20 Oct 2015
Edited: Mohsin Ali on 20 Oct 2015
hi i am using 64 bit version of matlab on 64 bit operating system windows 7. I am facing the same problem I have increasing the jave heap size and tried all the above recommendations. my computer specifications are, i am using it on Intel Xeon having 64GB of RAM. Matlab shows following results when I ran 'memory' and 'whos' commands
Maximum possible array: 124730 MB (1.308e+11 bytes)
Memory available for all arrays: 124730 MB (1.308e+11 bytes)
Memory used by MATLAB: 1014 MB (1.064e+09 bytes)
Physical Memory (RAM): 65535 MB (6.872e+10 bytes)
Limited by System Memory (physical + swap file) available.
Name Size Bytes Class Attributes
Problem 1x1 172686122 struct
cnt 1x1 8 double
index 1x1 1339842 struct
q 148770x148770 171455800 double sparse
x 1x1 8 double
y 1x1 8 double

1 Comment

Please start your own question rather than posting a question in an answer. And particularly, state what problem you are facing. As you've got tons of memory surely you're not running out of memory?
Note that changing OS settings (like process priority, page file size, etc.) without knowing the implication is not a good idea. The benefit may be marginal and result in instabilities.
Particularly, increasing the java heap size will reduce the memory available to matlab for array allocation. Just because it says memory in the setting does not mean it has anything to do with the memory used by matlab for arrays. This is memory used for java that affects things like GUI.

Sign in to comment.

Kalai Chelvi
Kalai Chelvi on 21 Nov 2016
HI, Am using a lap with 4GB RAM, 64 bit Win-7 OS and 64 bit Matlab-2013 version. When I am trying to use 'wavedec' command for an image of size 217x181 for level 1, I got "out of memory" error. Can any one tell me how to rectify it please ???

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!