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
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...@mathworks.com www.mathworks.com
"Steve " <chestnut...@ensco.com> wrote in message
news:fsgnts$f1d$1...@fred.mathworks.com...
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...@ensco.com> wrote in message
<fsgnts$f1d$1...@fred.mathworks.com>...
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
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
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)
>>