Note that there are some explanatory texts on larger screens.

plurals
  1. POMATLAB - run object destructor when using 'clear'?
    primarykey
    data
    text
    <p>Suppose I have a class <code>myClass &lt; handle</code>. From the <a href="http://www.mathworks.com/help/techdoc/ref/clear.html" rel="nofollow noreferrer"> Mathworks Help page on <code>clear</code></a>, </p> <blockquote> <p>Clearing handle graphics handles does not remove the objects themselves, nor does deleting the objects remove variables storing their handles.</p> </blockquote> <pre><code>hf = figure; % Creates figure object, stores handle in variable hf delete(hf) % Removes figure object, but not the variable hf clear hf % Removes hf from the workspace; figure could still exist </code></pre> <p>So <code>clear</code>ing a handle object does not remove it from memory unless I explicitly <code>delete</code> it first..</p> <p>I specified a destructor for <code>myClass</code> to do proper cleanup and remove some references to it; this destructor is not called upon <code>clear</code>. Is it possible to call that destructor when my object is cleared?</p> <p>EDIT: I should mention that while <code>delete</code> is automatically called with a <code>clear</code> if there are no references to the <code>myClass</code> object, I have another class, say <code>myOtherClass</code> with properties that refer to <code>myClass</code>, say <code>myOtherClass.a</code>. There are additionally other properties in <code>myOtherClass</code> that aren't properties of <code>myClass</code>, but they should be empty if <code>myOtherClass.a</code> is also empty. Let me know if that doesn't make sense, that might have been a bit too wordy.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload