Out of memory frustration

18 次查看(过去 30 天)
bethel o
bethel o 2013-4-9
Matlab is so nice but How I wish it can manage physical memory properly. It does not seem to know how to track the memory it allocates, It says 'out of memory' even when all other variables are cleared. If you restart it and try the same thing again it works but not for very long before it says 'out of memory' once again. It almost seem like the clearing variable has not effect other making the variable invisible.
Its so crazy because pack() which is meant to rescue the situation also gives out of memory error after it has deleted all your variables containing valuable data.
Please if anybody got a solution let me know, I really don't wanna throw this computer through the window if it says 'out of memory' just one more time!!!!!!!!!
Hopefully the computer geniuses at Mathworks will help us clear there footprints
  1 个评论
Yao Li
Yao Li 2013-4-9
try to improve your algorithm. For example, if you want to load data from an Excel or text file, try to load only a few columns or rows at a time instead of loading all the data as a large matrix.

请先登录,再进行评论。

回答(5 个)

per isakson
per isakson 2013-4-9
编辑:per isakson 2013-4-9
You should not trough the computer out of the window, even if says "out of memory". You might hurt someone in the street.
Matlab is not perfect, but it mostly recovers memory well. Speculations:
  • do you have some persistent data in a function or object?
  • there are tools to inspect memory use at the File Exchange and at Undocumented Matlab, e.g. Undocumented profiler options
  • Use Task Manager (Windows) to inspect the memory use
  • you have found a bug (memory leak). Report to the tech-support with all details.
  2 个评论
bethel o
bethel o 2013-4-9
I am on the sixth floor and its very windy, hopefully the wind will carry it safely to the bushes when I throw it, because i will certainly need it back when I have calmed down.
I do have a few global variables but they are mostly one element integers. Only one of the global variables is large about [48 x 1536 x 60]. Could this be my problem?
per isakson
per isakson 2013-4-9
>> [48 * 1536 * 60]*8/1e6
ans =
35.3894
>>
35MB is not the problem.

请先登录,再进行评论。


Jan
Jan 2013-4-9
You explained, that even pack fails with an out-of-memory error. pack stores the currently known variables in a MAT file, clears the memory and reloads the data. When this reloading fails, I cannot imagine how the value could fit into the memory before saving.
Exhausting the computer's memory is a general problem and not caused by Matlab itself. The same will happen in any programming language. The only strong solution is installing more RAM and running a 64 bit system, and installing even more RAM. Using smaller data types can help also, but this is a standard procedure and should be applied even if the computer does not crash to save resources.
  4 个评论
bethel o
bethel o 2013-4-9
@Jason Ross, I need realtime simulations and this as far as I know does not work well in 64bit matlab and software I have looked at won't work in 64bit.
Jan
Jan 2013-4-11
@bethel: It is not the question, if pack should be designed differently. The builtinin commands works as advertised, and it cannot perform magic. If the memory is "really" free'd depends on the operating system also. Here Windows7 is much smarter than e.g. XP. When your program calls Mex functions or DLLs, which produce memory leaks, restarting Matlab is the only way to free the memory, while pack cannot access the memory (otherwise it would not be a "leak").
Of course a simulation can run for years without exahsuting the memory, when it is carefully designed, or it can fill the memory in milliseconds. Such problems must be solved by the programmer (and the admin, who installs more RAM!), and neither Matlab nor the OS can catch this automagically.
I do not see any reason, why realtime simulation should run worse under 64 bit. When you have troubles with the limited memory, 64 bit (and more RAM) will definitely better than any drawbacks you expect for the actually more powerful system.

请先登录,再进行评论。


Mike
Mike 2013-4-9
You can try feature memstats periodically in your function and it might provide a clue as to what is growing? Maybe use the windows system monitors? cntrl-alt-delete to task manager, then performance tab and use the resource monitor button at the bottom? There are a few views of memory and maybe something else is growing? You went through the "doc Resolving "Out of Memory" Errors"?
A stupid suggestion, but maybe it will spur some "outside of the box" thinking, you might already be doing some of it. Is it possible to save your important data to file, clear everything and reload and restart from where you saved? There are apps out there for windows which will run
If your plot has a lot of data in it and you are using hold, it might be filling up memory? You can try just updating your plot with the latest data. You can just running it without the plot and see how much longer it runs? This is a really helpful discussion: http://undocumentedmatlab.com/blog/plot-performance/
>> feature memstats
Physical Memory (RAM):
In Use: 7142 MB ( 1be6bf000)
Free: 17430 MB ( 4416d7000)
Total: 24573 MB ( 5ffd96000)
Page File (Swap space):
In Use: 7302 MB ( 1c86f1000)
Free: 41842 MB ( a3726b000)
Total: 49145 MB ( bff95c000)
Virtual Memory (Address Space):
In Use: 8766 MB ( 223e7f000)
Free: 8379841 MB (7fddc161000)
Total: 8388607 MB (7fffffe0000)
Largest Contiguous Free Blocks:
1. [at 228010000] 8375214 MB (7fcbae30000)
2. [at 7feff031000] 4110 MB ( 100ec3000)
3. [at 17c030000] 63 MB ( 3fd0000)
4. [at 7feebfbb000] 47 MB ( 2fe5000)
5. [at 13e400000] 28 MB ( 1c00000)
6. [at 7feeefb7000] 24 MB ( 18e9000)
7. [at 7fee4fec000] 24 MB ( 1844000)
8. [at 7bc66000] 17 MB ( 11aa000)
9. [at 7fef0920000] 14 MB ( ef0000)
10. [at 7fee9139000] 14 MB ( ed7000)
======= ==========
8379561 MB (7fdca946000)
ans =
8782048591872

bethel o
bethel o 2013-4-10
So after whinging at everybody about my life and how is all ruined by this 32bit computer and matlab and memory and global warming, yeah, I just got sorted with a 64bit machine runing 64bit matlab. This thing is gold mine. Life is good!!!
Thanks to everyone for all your suggestions, they were all useful!
Bethel

Walter Roberson
Walter Roberson 2013-4-9
Are you deleting all the graphics objects as well ?
  3 个评论
Jan
Jan 2013-4-9
If you have one figure, but create new objects e.g. by image() without deleting the formerly created objects, the memory will be exhausted after a certain number of operations. None of the clearing commands would be helpful then. My impression is, that clearing ios useful under rare conditions only in Matlab.
bethel o
bethel o 2013-4-9
OK. Do you know how to properly clear the graphics objects?
Thanks

请先登录,再进行评论。

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by