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 all doesn't clear the entire memory

Subject: Clear all doesn't clear the entire memory

From: Bluebird

Date: 16 Sep, 2010 17:45:24

Message: 1 of 10

Hello,

Sometimes, and when i run some files (especially the MEX files), my memory gets full.

Clear all command doenst erase the entire memory therefore i am forced to close and open matlab again.

Any advice on how can i clear my memory without having to close and open matlab ?

Thank you

Subject: Clear all doesn't clear the entire memory

From: dpb

Date: 16 Sep, 2010 18:24:15

Message: 2 of 10

Bluebird wrote:
> Hello,
>
> Sometimes, and when i run some files (especially the MEX files), my
> memory gets full.

> Clear all command doenst erase the entire memory therefore i am forced
> to close and open matlab again.
...

Sounds as though likely the MEX files aren't releasing all their memory
if it occurs mostly with them.

Which OS? Not sure Windoes is very good about actually releasing
process memory even if requested--newer versions may be better in that
regard???

--

Subject: Clear all doesn't clear the entire memory

From: Bluebird

Date: 16 Sep, 2010 18:33:25

Message: 3 of 10

Thank you. I use windows XP, yet i have 7 in another computer and still have the same issue.

The problem is, I know close to nothing when it comes to MEX file, so i don't know all the stuff about releasing memory :(...

Subject: Clear all doesn't clear the entire memory

From: dpb

Date: 16 Sep, 2010 18:37:08

Message: 4 of 10

Bluebird wrote:
> Thank you. I use windows XP, yet i have 7 in another computer and still
> have the same issue.
> The problem is, I know close to nothing when it comes to MEX file, so i
> don't know all the stuff about releasing memory :(...

Well, assuming these are files you wrote, time to start debugging them.
  Excepting for variables created explicitly to be passed back to the
Matlab workspace, any and all memory allocated within the Mex function
has to be released there as well to avoid memory leaks. That shouldn't
be too hard to follow.

OTOH, if they're from somewhere else then you're stuck unless you have
the source.

--

Subject: Clear all doesn't clear the entire memory

From: someone

Date: 16 Sep, 2010 18:44:12

Message: 5 of 10

"Bluebird " <wlouis@ryerson.ca> wrote in message <i6tntl$7oe$1@fred.mathworks.com>...
> Thank you. I use windows XP, yet i have 7 in another computer and still have the same issue.
>
> The problem is, I know close to nothing when it comes to MEX file, so i don't know all the stuff about releasing memory :(...

doc clear

% did you try:

clear functions

% Clears all the currently compiled M-functions and MEX-functions from memory.
% Using clear function removes debugging breakpoints in the function M-file and reinitializes persistent variables, since the breakpoints for a function and persistent variables are cleared whenever the M-file is changed or cleared.

Subject: Clear all doesn't clear the entire memory

From: Bluebird

Date: 16 Sep, 2010 18:58:21

Message: 6 of 10

"someone" <someone@somewhere.net> wrote in message <i6tohs$iei$1@fred.mathworks.com>...
> "Bluebird " <wlouis@ryerson.ca> wrote in message <i6tntl$7oe$1@fred.mathworks.com>...
> > Thank you. I use windows XP, yet i have 7 in another computer and still have the same issue.
> >
> > The problem is, I know close to nothing when it comes to MEX file, so i don't know all the stuff about releasing memory :(...
>
> doc clear
>
> % did you try:
>
> clear functions
>
> % Clears all the currently compiled M-functions and MEX-functions from memory.
> % Using clear function removes debugging breakpoints in the function M-file and reinitializes persistent variables, since the breakpoints for a function and persistent variables are cleared whenever the M-file is changed or cleared.

I will give it a shot.. I thought clear all includes all the subsequent things (i.e. classes, functions, java etc).

Subject: Clear all doesn't clear the entire memory

From: Bluebird

Date: 16 Sep, 2010 19:03:24

Message: 7 of 10

"Bluebird " <wlouis@ryerson.ca> wrote in message <i6tpcd$dl3$1@fred.mathworks.com>...
> "someone" <someone@somewhere.net> wrote in message <i6tohs$iei$1@fred.mathworks.com>...
> > "Bluebird " <wlouis@ryerson.ca> wrote in message <i6tntl$7oe$1@fred.mathworks.com>...
> > > Thank you. I use windows XP, yet i have 7 in another computer and still have the same issue.
> > >
> > > The problem is, I know close to nothing when it comes to MEX file, so i don't know all the stuff about releasing memory :(...
> >
> > doc clear
> >
> > % did you try:
> >
> > clear functions
> >
> > % Clears all the currently compiled M-functions and MEX-functions from memory.
> > % Using clear function removes debugging breakpoints in the function M-file and reinitializes persistent variables, since the breakpoints for a function and persistent variables are cleared whenever the M-file is changed or cleared.
>
> I will give it a shot.. I thought clear all includes all the subsequent things (i.e. classes, functions, java etc).

Clear functions doenst help !

Subject: Clear all doesn't clear the entire memory

From: dpb

Date: 16 Sep, 2010 19:28:36

Message: 8 of 10

Bluebird wrote:
...

> Clear functions doenst help !

Of course not if your functions have memory leak(s)...

--

Subject: Clear all doesn't clear the entire memory

From: David

Date: 16 Sep, 2010 19:35:21

Message: 9 of 10

"Bluebird " <wlouis@ryerson.ca> wrote in message <i6tpls$3m1$1@fred.mathworks.com>...
> "Bluebird " <wlouis@ryerson.ca> wrote in message <i6tpcd$dl3$1@fred.mathworks.com>...
> > "someone" <someone@somewhere.net> wrote in message <i6tohs$iei$1@fred.mathworks.com>...
> > > "Bluebird " <wlouis@ryerson.ca> wrote in message <i6tntl$7oe$1@fred.mathworks.com>...
> > > > Thank you. I use windows XP, yet i have 7 in another computer and still have the same issue.
> > > >
> > > > The problem is, I know close to nothing when it comes to MEX file, so i don't know all the stuff about releasing memory :(...
> > >
> > > doc clear
> > >
> > > % did you try:
> > >
> > > clear functions
> > >
> > > % Clears all the currently compiled M-functions and MEX-functions from memory.
> > > % Using clear function removes debugging breakpoints in the function M-file and reinitializes persistent variables, since the breakpoints for a function and persistent variables are cleared whenever the M-file is changed or cleared.
> >
> > I will give it a shot.. I thought clear all includes all the subsequent things (i.e. classes, functions, java etc).
>
> Clear functions doenst help !


The person above is right. it's something to do with your mex file. if it's written in c++ then you probably don't have a destructor for one of your constructors. so as said before, either fix the mex file, or close then restart matlab every time you have a problem

Subject: Clear all doesn't clear the entire memory

From: Bluebird

Date: 16 Sep, 2010 20:03:25

Message: 10 of 10

Many thanks for your help people. I will see if I can fix the mex file otherwise i will live with the restart thing :).

Regards

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