Hello, I'm having some trouble clearing the classes (Using
r2008a) when I make a change. When I type clear classes I
get several messages like:
Warning: Objects of 'SomeClassIWrote' class exist. Cannot
clear this class or any of its super-classes.
'clear all' doesn't report any warnings but it also doesn't
actually clear the classes because I still get the same
error if I type 'clear classes' again. The handles seem to
be getting lost somewhere. They're not in referenced in
persistent or global variables and are not in my workspace.
Is there a way I can get all handles to delete them
properly? Like a h=findobj() that works for all handles
rather than just handle graphics? What should I do to
prevent this problem, I thought Matlab's garbage collection
was supposed to take care of this?
The "clear classes" first executes a "clear all" and then clears any classes
with no outstanding instances. "clear all" does not itself attempt to clear
any classes which is why you don't see any warnings. It sounds like you
have already checked the most likely places for objects to be kept (global
or persistent variables). If you are using any graphics or Java objects,
your objects could also be held by callbacks or in UserData of those
objects. There is no way to get a list of all objects you create, but they
are not supposed to persist if no longer referenced from anywhere.
"Steve " <chestnut.stephen@ensco.com> wrote in message
news:fsgnts$f1d$1@fred.mathworks.com...
> Hello, I'm having some trouble clearing the classes (Using
> r2008a) when I make a change. When I type clear classes I
> get several messages like:
>
> Warning: Objects of 'SomeClassIWrote' class exist. Cannot
> clear this class or any of its super-classes.
>
> 'clear all' doesn't report any warnings but it also doesn't
> actually clear the classes because I still get the same
> error if I type 'clear classes' again. The handles seem to
> be getting lost somewhere. They're not in referenced in
> persistent or global variables and are not in my workspace.
>
> Is there a way I can get all handles to delete them
> properly? Like a h=findobj() that works for all handles
> rather than just handle graphics? What should I do to
> prevent this problem, I thought Matlab's garbage collection
> was supposed to take care of this?
>
> Thank you,
> Steve
there might be a problem with your property definitions. Do
you initialize a property to an anonymous function? It
seems you cannot do that. The function handle keeps a
reference to the workspace in which it was created and
therefore contains a reference to the object you are
creating. The "clear all" command misses clearing this
reference, so "clear classes" will fail.
Here is an example of this behavior:
classdef TestClearClass
properties
f = @(x) x;
end
methods
end
end
In the command window:
>> c = TestClearClass;
>> clear classes
Warning: Objects of 'TestClearClass' class exist. Cannot
clear this class or any of its super-classes.
Hope this helps,
Joe
"Steve " <chestnut.stephen@ensco.com> wrote in message
<fsgnts$f1d$1@fred.mathworks.com>...
> Hello, I'm having some trouble clearing the classes
(Using
> r2008a) when I make a change. When I type clear classes I
> get several messages like:
>
> Warning: Objects of 'SomeClassIWrote' class exist. Cannot
> clear this class or any of its super-classes.
>
> 'clear all' doesn't report any warnings but it also
doesn't
> actually clear the classes because I still get the same
> error if I type 'clear classes' again. The handles seem
to
> be getting lost somewhere. They're not in referenced in
> persistent or global variables and are not in my
workspace.
>
> Is there a way I can get all handles to delete them
> properly? Like a h=findobj() that works for all handles
> rather than just handle graphics? What should I do to
> prevent this problem, I thought Matlab's garbage
collection
> was supposed to take care of this?
>
> Thank you,
> Steve
I am running into the same problem. I also am using other class
constructors in initializing properties. Later i may do something like;
class2.aprop = myClass1Instance;
Does this lose the original handle/reference such that clear all can't
find it?
Jan
Steve wrote:
> I don't use any anonymous function handles for initializing
> properties though I do use other class constructors like
>
> classdef class2 < handle
>
> properties
> aprop = class1();
> end
>
> end
>
> But I don't think that should cause any problems. I'm
> putting together an example that I can distribute, I'll post
> it here when I finish it.
>
> Thanks,
> Steve
"Dave Foti" <daf@mathworks.com> wrote in message <fsj0p2
$oeh$1@fred.mathworks.com>...
> Hi Steve,
>
>
>
> The "clear classes" first executes a "clear all" and then
clears any classes
> with no outstanding instances. "clear all" does not
itself attempt to clear
> any classes which is why you don't see any warnings. It
sounds like you
> have already checked the most likely places for objects
to be kept (global
> or persistent variables). If you are using any graphics
or Java objects,
> your objects could also be held by callbacks or in
UserData of those
> objects. There is no way to get a list of all objects
you create, but they
> are not supposed to persist if no longer referenced from
anywhere.
>
>
>
> -Dave
>
> ----------------------------------------------------------
-
>
> Dave Foti The MathWorks
>
> Dave.Foti@mathworks.com
www.mathworks.com
>
I tried the example of the new FEX-contribution, "Yet
Another Layout Manager" and now it seems it left objects
that I cannot clear.
/ per
Copy from the command window :
>> inmem
ans =
'workspacefunc'
'imformats'
'arrayviewfunc'
>> clear all, clear classes
Warning: Objects of 'RE_Tabpane' class exist. Cannot clear
this class or any of its super-classes.
Warning: Objects of 'RE_Axis' class exist. Cannot clear
this class or any of its super-classes.
Warning: Objects of 'RE_Button' class exist. Cannot clear
this class or any of its super-classes.
>> version
ans =
7.6.0.324 (R2008a)
>>
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.