Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
CLEAR matrix yet the memory is full ?

Subject: CLEAR matrix yet the memory is full ?

From: Louis

Date: 12 Nov, 2010 18:08:04

Message: 1 of 4

Hello I have this scenario:

%%Step 1
>>clear all;
>>memory: Maximum possible array: 1257 MB (1.318e+009 bytes) *
                               Memory available for all arrays: 1497 MB (1.569e+009 bytes) **
                               Memory used by MATLAB: 327 MB (3.430e+008 bytes)
                               Physical Memory (RAM): 3543 MB (3.715e+009 bytes)


%%Step 2
>>H1=zeros(3000,6000);
>>H2=zeros(3000,6000);
>>memory Maximum possible array: 982 MB (1.030e+009 bytes) *
                                Memory available for all arrays: 1222 MB (1.281e+009 bytes) **
                                Memory used by MATLAB: 602 MB (6.311e+008 bytes)
                                Physical Memory (RAM): 3543 MB (3.715e+009 bytes)

%% Step 3
>>H3=[H1 H2];
>> memory Maximum possible array: 707 MB (7.415e+008 bytes) *
                                 Memory available for all arrays: 947 MB (9.933e+008 bytes) **
                                 Memory used by MATLAB: 876 MB (9.191e+008 bytes)
                                 Physical Memory (RAM): 3543 MB (3.715e+009 bytes)

Now if I
>> clear H1 H2
(now H1 and H2 are not in the workspace anymore)

shouldnt i be supposed to go back to the memory shown in Step 2??? however i am getting the memory shows in Step 3 :S ..

Can you please advise what am i doing wrong or how can i go back to the memory of Step 2...

Many thanks

Louis

Subject: CLEAR matrix yet the memory is full ?

From: Steven_Lord

Date: 12 Nov, 2010 18:27:27

Message: 2 of 4



"Louis " <wlouis@ryerson.ca> wrote in message
news:ibjvq4$rfl$1@fred.mathworks.com...
> Hello I have this scenario:
>
> %%Step 1
>>>clear all;
>>>memory: Maximum possible array: 1257 MB
>>>(1.318e+009 bytes) *
> Memory available for all arrays: 1497 MB
> (1.569e+009 bytes) **
> Memory used by MATLAB: 327 MB
> (3.430e+008 bytes)
> Physical Memory (RAM): 3543 MB
> (3.715e+009 bytes)
>
>
> %%Step 2
>>>H1=zeros(3000,6000);
>>>H2=zeros(3000,6000);
>>>memory Maximum possible array: 982 MB
>>>(1.030e+009 bytes) *
> Memory available for all arrays: 1222 MB
> (1.281e+009 bytes) **
> Memory used by MATLAB: 602 MB
> (6.311e+008 bytes)
> Physical Memory (RAM): 3543 MB
> (3.715e+009 bytes)
>
> %% Step 3
>>>H3=[H1 H2];
>>> memory Maximum possible array: 707 MB
>>> (7.415e+008 bytes) *
> Memory available for all arrays: 947 MB
> (9.933e+008 bytes) **
> Memory used by MATLAB: 876 MB
> (9.191e+008 bytes)
> Physical Memory (RAM): 3543 MB
> (3.715e+009 bytes)
>
> Now if I
>>> clear H1 H2
> (now H1 and H2 are not in the workspace anymore)
>
> shouldnt i be supposed to go back to the memory shown in Step 2??? however
> i am getting the memory shows in Step 3 :S ..

No for several reasons, the most obvious of which is that H3 is still in
your workspace.

See the Technical Support guides on memory management for more information
about how memory works in MATLAB. They're 1106 and 1107 on this page:

http://www.mathworks.com/support/tech-notes/list_all.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: CLEAR matrix yet the memory is full ?

From: Bruno Luong

Date: 12 Nov, 2010 19:45:05

Message: 3 of 4

"Louis " <wlouis@ryerson.ca> wrote in message <ibjvq4$rfl$1@fred.mathworks.com>...

>
> shouldnt i be supposed to go back to the memory shown in Step 2??? however i am getting the memory shows in Step 3 :S ..

Odd, when I test I get the *most* of total memory back, as expected.

Note that we can't expect the biggest block size unchanged, because the memory might be fragmented.

Here is my test output:

>> memory
Maximum possible array: 5492 MB (5.759e+009 bytes) *
Memory available for all arrays: 5492 MB (5.759e+009 bytes) *
Memory used by MATLAB: 391 MB (4.102e+008 bytes)
Physical Memory (RAM): 3758 MB (3.941e+009 bytes)

* Limited by System Memory (physical + swap file) available.
>> H1=zeros(3000,6000);
>> H2=zeros(3000,6000);
>> memory
Maximum possible array: 5210 MB (5.463e+009 bytes) *
Memory available for all arrays: 5210 MB (5.463e+009 bytes) *
Memory used by MATLAB: 664 MB (6.965e+008 bytes)
Physical Memory (RAM): 3758 MB (3.941e+009 bytes)

* Limited by System Memory (physical + swap file) available.
>> H3=[H1 H2];
>> memory
Maximum possible array: 4931 MB (5.170e+009 bytes) *
Memory available for all arrays: 4931 MB (5.170e+009 bytes) *
Memory used by MATLAB: 939 MB (9.845e+008 bytes)
Physical Memory (RAM): 3758 MB (3.941e+009 bytes)

* Limited by System Memory (physical + swap file) available.
>> clear H1 H2
>> memory
Maximum possible array: 5205 MB (5.458e+009 bytes) *
Memory available for all arrays: 5205 MB (5.458e+009 bytes) *
Memory used by MATLAB: 664 MB (6.966e+008 bytes)
Physical Memory (RAM): 3758 MB (3.941e+009 bytes)

* Limited by System Memory (physical + swap file) available.
>>

Bruno

Subject: CLEAR matrix yet the memory is full ?

From: Louis

Date: 12 Nov, 2010 20:12:03

Message: 4 of 4

Thank you guys.

I read the document Steve given and it was more than adequate to make me understand the memory management....

Bruno: true, i wasnt aware about the fragment issue.... BTW, you have an awesome computer, why dont i send you my code and you get me out of this trouble... jksss :)

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us