D
David Abdala
Guest
I always recommend to explicitly delete objects that you don't longer need. That not only ensures there are no "hanging around objects" but also helps others understand the code. Think about another programmer looking at the code: - The object is not deleted because is garbage collected - The object is not deleted because is used somewhere else - The object is not deleted because is internally referenced by global objects You should document that, it's a lot easier to just delete the object. Explicitly deleting objects has no drawbacks, not doing so does. Garbage collection is a great feature but should not be used as a "programming practice" because it may bite you harder than you can imagine, and if that happens the only solution will be to go back to the code and add all the "missing deletes". In your original example, adding a FINALLY block where you DELETE the object, is more than enough, and puts your intentions very clearly. My first thinking of your example was that you created 100 objects to do a "parallel" sort of stuff with all of them, only because there was no DELETE statement.. (yes, I know I'm weird..)
Continue reading...
Continue reading...