I'm sorry for such a broad question but I'm having trouble finding a decent explanation of how objects are deleted or what happens when objects are deleted (and in particular, user defined objects), i.e. what is Matlab's garbage collection process. For example, suppose I create an instance of MyObject, which is a hypothetical class may contain lots of data including other objects.
A = MyObject();
If I need to create a new instance of MyObject and I don't need the old instance anymore, how do I do so and ensure all the memory used by A gets cleared, all objects within A get deleted, any files that may have been opened get closed, you name it? Do I need to set A to ? Do I need to call "clear A"? Will setting just setting A to MyObject() in another statement be enough?
I've noticed that the "Handle" class has a method called "delete." Am I required to subclass delete and add all the garbage collection there? If so, must I called garbage collection explicitly or will Matlab call it for me (say in the cases I mentioned in the previous paragraph)?
A link to an existing explanation of all this would suffice.
A very large number of "Thank you"'s to anyone who can answer this for me.