Consider the following:
Consider the following...
1) Type "[ code ]" without the spaces, hit enter then type "[ /code ]".
2) Copy your... wait for it... "code" from your IDE.
3) Paste your code on the line with the code tag.
The thing to watch out for is whether you have any pointers defined in the classes you are creating, like links in a linked list, as an example. Unless the destructor defined in the static object explicitly deletes any dynamically created objects that are members of the static object's state, those objects will continue to occupy memory in the heap after the static object has been released.
There are a couple things worth covering here...
1a) Although your "watch out for this" point is valid, the OOP example sort of muddies the water regarding memory leaks and pointers. Just to be extra clear for the newbies... OOP and memory allocation are two, not necessarily related, topics. You can allocate objects on the stack or heap; however, you don't have to use OOP in order to allocate memory on the heap.
1b) It is NOT a good idea to use OOP in the manner that jasonfactor did here. He is providing an example using some skeleton code. Instantiating and destroying an object in this manner is not a good idea.
1c) Finally, this is also a bad example of garbage collection... jk. =)
2) Again, just to be extra clear for the newbies. Should an abstract data type destroy it's contents upon destruction? For instance, I have a bunch of Foo that I iterate over doing various operations. I also have a heap of the same Foo that keeps things ordered based on one of the fields in Foo. Now I no longer need either the list or the heap... I'm not going to appreciate your ADT destroying all of my objects! What Jasonfactor is saying is that you should also destroy any supporting objects like Nodes that will typically be instantiated by the LinkedList class.