Thread Subject:
Memory usage does not reduce

Subject: Memory usage does not reduce

From: Lucas

Date: 5 Jul, 2012 21:37:07

Message: 1 of 6

Hi all,

I notice that even after a 'clear all' command, Matlab still appears to hold on to hundreds of MBs of memory as shown in the Windows task manager. How do I force Matlab to free up those memory?

Thanks,
Lucas

Subject: Memory usage does not reduce

From: Nasser M. Abbasi

Date: 5 Jul, 2012 23:16:54

Message: 2 of 6

On 7/5/2012 4:37 PM, Lucas wrote:
> Hi all,
>
> I notice that even after a 'clear all' command, Matlab still appears to hold
>on to hundreds of MBs of memory as shown in the Windows task manager. How
>do I force Matlab to free up those memory?

I did this on windows:

1) started Matlab. Memory was 170 MB according to task manager
2) A=size(2000); Memory now jumped to 201 MB
3) clear all; Memory went to 179 MB again

Repeated steps 2-3, same results.

Do you obtain different behavior on your end?

I discovered that the only way to clear those 170 MB left is
to close Matlab.

--Nasser
“Heavier-than-air flying machines are impossible.” Lord Kelvin, 1895
“Everything that can be invented has been invented.” Charles H. Duell, 1899

Subject: Memory usage does not reduce

From: Nasser M. Abbasi

Date: 5 Jul, 2012 23:24:04

Message: 3 of 6

On 7/5/2012 6:16 PM, Nasser M. Abbasi wrote:
> On 7/5/2012 4:37 PM, Lucas wrote:
>> Hi all,
>>
>> I notice that even after a 'clear all' command, Matlab still appears to hold
>> on to hundreds of MBs of memory as shown in the Windows task manager. How
>> do I force Matlab to free up those memory?
>
> I did this on windows:
>
> 1) started Matlab. Memory was 170 MB according to task manager
> 2) A=size(2000); Memory now jumped to 201 MB
> 3) clear all; Memory went to 179 MB again

opps, typo: 179 above is meant to be 170. i.e. went back to
original size.
  
> Repeated steps 2-3, same results.

--Nasser

Subject: Memory usage does not reduce

From: Lucas

Date: 6 Jul, 2012 21:12:08

Message: 4 of 6

Hey, Thanks for your reply.

For a simple case like that, the memory will be reclaimed by the OS.
But whenever I load large excel files, and do a 'clear all' after that, the memory doesn't go down. In general, after a complex script is executed, the memory just isn't reclaimed.
Any ideas?

Are there any hidden 'vars' to clear as well?

Lucas




"Nasser M. Abbasi" <nma@12000.org> wrote in message <jt57mn$6lr$1@speranza.aioe.org>...
> On 7/5/2012 6:16 PM, Nasser M. Abbasi wrote:
> > On 7/5/2012 4:37 PM, Lucas wrote:
> >> Hi all,
> >>
> >> I notice that even after a 'clear all' command, Matlab still appears to hold
> >> on to hundreds of MBs of memory as shown in the Windows task manager. How
> >> do I force Matlab to free up those memory?
> >
> > I did this on windows:
> >
> > 1) started Matlab. Memory was 170 MB according to task manager
> > 2) A=size(2000); Memory now jumped to 201 MB
> > 3) clear all; Memory went to 179 MB again
>
> opps, typo: 179 above is meant to be 170. i.e. went back to
> original size.
>
> > Repeated steps 2-3, same results.
>
> --Nasser

Subject: Memory usage does not reduce

From: dpb

Date: 6 Jul, 2012 21:38:55

Message: 5 of 6

On 7/6/2012 4:12 PM, Lucas wrote:
> Hey, Thanks for your reply.
>
> For a simple case like that, the memory will be reclaimed by the OS.
> But whenever I load large excel files, and do a 'clear all' after that,
> the memory doesn't go down. In general, after a complex script is
> executed, the memory just isn't reclaimed.
> Any ideas?
...

Matlab can mark the memory as freed but once it's fragmented it's tough
to ever get contiguous memory back. AFAIK you're under the thumb of the
OS to reclaim what it can when it decides it wants to but that ain't
often until the app is closed and then it releases everything associated
with it.

IOW, there's not much you can do during a session...

--

Subject: Memory usage does not reduce

From: Matt J

Date: 6 Jul, 2012 21:43:09

Message: 6 of 6

"Lucas" wrote in message <jt51e3$884$1@newscl01ah.mathworks.com>...
> Hi all,
>
> I notice that even after a 'clear all' command, Matlab still appears to hold on to hundreds of MBs of memory as shown in the Windows task manager. How do I force Matlab to free up those memory?
=============

what about when you do

clear classes; clear functions; close all

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
memory Lucas 5 Jul, 2012 17:39:11
usage Lucas 5 Jul, 2012 17:39:11
high Lucas 5 Jul, 2012 17:39:11
reduce Lucas 5 Jul, 2012 17:39:11
rssFeed for this Thread

Contact us