Error Out of memory.
Mostrar comentarios más antiguos
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.
Respuestas (2)
Jan
el 23 de Mzo. de 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 comentarios
Lucy Gillis
el 23 de Mzo. de 2017
Editada: Jan
el 23 de Mzo. de 2017
Jan
el 23 de Mzo. de 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
el 23 de Mzo. de 2017
Jan
el 23 de Mzo. de 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
el 23 de Mzo. de 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
el 24 de Mzo. de 2017
Rik
el 24 de Mzo. de 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
el 24 de Mzo. de 2017
Rik
el 23 de Mzo. de 2017
0 votos
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 comentario
Lucy Gillis
el 23 de Mzo. de 2017
Categorías
Más información sobre Profile and Improve Performance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!