Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Out of Memory
Date: Fri, 3 Apr 2009 16:46:02 +0000 (UTC)
Organization: University College Dublin
Lines: 51
Message-ID: <gr5ega$t7f$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1238777162 29935 172.30.248.37 (3 Apr 2009 16:46:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 3 Apr 2009 16:46:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 87230
Xref: news.mathworks.com comp.soft-sys.matlab:530095


Can anyone explain the following behavior on a 16GB machine. Notice that the memory error occurs in two different places : `plus' and 'mtimes'.

>> clear all;

>> n = 2.5*10^4;

% --- GBytes = 8*n^2/10^9;

% --- Memory needed for each nxn matrix = 5GB;

>> C = rand(n,n);  D = rand(n,n);

% ---  WTM records total memory in use 12.6GB.  2.6 (OS + ?) +(5+5) matrices: checks

>> whos
  Name          Size                    Bytes  Class     Attributes

  C         25000x25000            5000000000  double              
  D         25000x25000            5000000000  double              
  n             1x1                         8  double              

>> memory
Maximum possible array:               3498 MB (3.667e+009 bytes) *
Memory available for all arrays:      3498 MB (3.667e+009 bytes) *
Memory used by MATLAB:                9929 MB (1.041e+010 bytes)
Physical Memory (RAM):               16381 MB (1.718e+010 bytes)


>> C = 2*C;
??? Error using ==> mtimes
Out of memory. Type HELP MEMORY for your options

>> C = C+C;
??? Error using ==> plus
Out of memory. Type HELP MEMORY for your options.

for i = 1:n, for j = 1:n, C(i,j) = 2*C(i,j);end;end;  % --- works ok ---
>> % --- Interrupted at keyboard after 5mins ---

>>for i = 1:n, for j = 1:n, C(i,j) = C(i,j)+C(i,j);end;end;  % --- works ok ---
>> % --- Interrupted at keyboard after 5mins ---

>> ver
-------------------------------------------------------------------------------------
MATLAB Version 7.6.0.324 (R2008a)
MATLAB License Number: 
Operating System: Microsoft Windows Vista Version 6.0 (Build 6001: Service Pack 1)
Java VM Version: Java 1.6.0 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
-------------------------------------------------------------------------------------

Derek O'Connor