MATLAB - how to increase memory?

Click For Summary

Discussion Overview

The discussion centers around the issue of memory management in MATLAB, particularly regarding how to increase the memory available for computations. Participants explore various strategies to handle large matrices and optimize memory usage, including the use of MATLAB's Parallel Computing Toolbox and algorithmic adjustments.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Exploratory

Main Points Raised

  • One participant describes their problem with MATLAB's memory limitations, detailing the sizes of their matrices and the errors encountered when attempting to use a transpose.
  • Another participant suggests using the Parallel Computing Toolbox to partition arrays across different computers, sharing memory space.
  • A different viewpoint questions the effectiveness of the Parallel Computing Toolbox, noting that all data may still need to fit on the main node.
  • One participant proposes that the algorithm could be rewritten to avoid creating a second copy of the matrix by referencing elements directly, thus saving memory.
  • Another participant acknowledges the potential for parallelizing a large matrix and its transpose without saving it on the client but admits to limited resources and knowledge on the topic.

Areas of Agreement / Disagreement

Participants express differing opinions on the effectiveness of the Parallel Computing Toolbox and the best strategies for managing memory in MATLAB. There is no consensus on a single solution, and multiple approaches are discussed.

Contextual Notes

Participants mention the limitations of physical memory and virtual memory, as well as the implications of increasing RAM or using Windows switches to adjust memory limits. The discussion reflects uncertainty regarding the best practices for memory management in MATLAB.

Who May Find This Useful

This discussion may be useful for MATLAB users facing memory limitations, particularly those working with large datasets or matrices, as well as those interested in optimization techniques and parallel computing strategies.

mikeph
Messages
1,229
Reaction score
18
Hello,

I have a problem with my code, it uses too much memory. Aside from optimisation of the code (which I am constantly working on), how can I increase the memory which is available to MATLAB?

Code:
>> memory
Maximum possible array:             435 MB (4.564e+008 bytes) *
Memory available for all arrays:    902 MB (9.463e+008 bytes) **
Memory used by MATLAB:              820 MB (8.601e+008 bytes)
Physical Memory (RAM):             1980 MB (2.076e+009 bytes)

*  Limited by contiguous virtual address space available.
** Limited by virtual address space available.

I understand why RAM is limited, but I can't understand in the help file how I can increase the memory used by MATLAB.

I have three matrices in my workspace, two are about 1 MB and the third is huge (it is a sparse double matrix with 30 million elements), about 255 MB. I am trying to implement an algorithm which uses this matrix, and its transpose, and the code always fails when it needs to use the transpose, presumably because it needs another 255 MB to store the result.

But the memory for all arrays is 920 MB , and I have no array which is larger than 435 MB, so I don't understand what is taking up so much space.

Is there a MATLAB command that I can do which effectively says "ok you are allowed to use 1.5 GB of my 1.98 GB physical memory so do whatever you want? Or if this fails, and I buy more RAM, (and apparently you can use a windows switch to increase the max for anyone program from 2 to 3 GB), will it even help my problem?


Thanks for any help,
 
Physics news on Phys.org
Wrichik Basu said:
Use the Parallel Computing Toolbox of Matlab. You'll be able to partition the array into different computers, thereby sharing the memory space.
I'm not sure that this would work. From what I understand of the way Matlab is parallelized, all data will still need to fit on the main node.

Without changing anything to the code, I see two possibilities. The best is to increase the memory on the computer. If that is not possible, it might be possible to increase the amount of virtual memory. The latter would most probably result in a much slower execution, however.
 
The transpose doesn't have any additional information so there isn't really a need to create that second copy of your matrix. Can you rewrite the algorithm to work with just the original matrix, reference A(j,i) when you want the (i,j)-th element of A'?
 
  • Like
Likes   Reactions: Wrichik Basu
DrClaude said:
I'm not sure that this would work. From what I understand of the way Matlab is parallelized, all data will still need to fit on the main node.
It can be done; I had seen someone parallelizing a huge matrix and it's transpose without saving it on the client. But I don't remember how he did it. Very limited resources exist on the net regarding the parallel computing toolbox. I'll try to get hold of the exact code by posting in matlab's community forums.
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
11K