Error Out of memory.
Afficher commentaires plus anciens
I had a "Out of memory. Type HELP MEMORY for your options"
I added 2 GB to my RAM so that according to the HELP MEMORY this would be enough to complete the script. However I now get the same error and HELP MEMORY states that I now need even more memory. The memory that it states I need is always just over what is available in RAM. I know I am doing something basically stupid here, but I do not know what.
Réponses (2)
Jan
le 23 Mar 2017
Please post any details: The relevant part of the code and the absolute size of the memory (adding 2 GB to a 64 GB machine will not be trustworthy).
You do not need only a certain amount of RAM, but for allocating large arrays, there must be a free contiguous block of memory available. If one byte is reserved in between for another variable, the memory is not available as block anymore. This is called "memory fragmentation" and it cannot be controlled directly. Use this for checking:
feature('memstats')
A missing pre-allocation can lead to a fragmentation of teh memory.
8 commentaires
Lucy Gillis
le 23 Mar 2017
Modifié(e) : Jan
le 23 Mar 2017
Jan
le 23 Mar 2017
The fragmentation of the memory means the RAM, not the hard-disk. Usually the RAM is fragmented in some milliseconds, while hard disks tend to take weeks for substantial fragmentations.
Please explain, what "trim" is. If it is a large system, most likely the final answer will be: This cannot be computed on a 32 bit machine.
Lucy Gillis
le 23 Mar 2017
Jan
le 23 Mar 2017
@Lucy: It does not matter how large the struct is, but its contents define the problem to solve. E.g. rand(1e6) is a small code, but produces a huge array. Currently we still cannot even guess, what kind of problem you try to solve. Perhaps it is a typo only like in rand(1e6) when rand(1, 1e6) is meant.
Rik
le 23 Mar 2017
You may also use the step-by-step feature in the debugger to find out what is happening. That is usually the easiest way to spot errors like rand(1e6) instead of rand(1,1e6).
Lucy Gillis
le 24 Mar 2017
Rik
le 24 Mar 2017
I meant using break points etc. You should be able to activate one by clicking next to the line number in the editor.
Lucy Gillis
le 24 Mar 2017
Rik
le 23 Mar 2017
0 votes
The list below is shamelessly copied from Jan Simon. Seeing as this some of these suggested solutions seem not to work, there are two options. You either need to offer more details about your code, or you need to try the other suggestions from this list.
- Install more RAM
- Care for a proper pre-allocation to reduce memory fragmentation
- Install more RAM
- Run a 64-bit version of Matlab
- Install more RAM
- Close other applications
- Install more RAM
- Use the smallest data type, which represents your data exactly, e.g. a single occupies 4 bytes instead of 8 for a double.
- Install more RAM
- Increase the virtual memory
- But guess, if real RAM is better than virtual...
(If you are really, really desperate, you could consider converting your code to loops, but don't tell anyone I said that.)
1 commentaire
Lucy Gillis
le 23 Mar 2017
Catégories
En savoir plus sur Profile and Improve Performance dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!