Re:Friendship ended with the garbage collector
by nine_k on Friday August 27, 2021 @01:10PM
(#28330369)
Easy: objects should not normally have members with different lifetimes, and ideally any mutable members at all.
There are exceptions to that, like queues and caches, but they are few and should be closely watched.
Remembering to null references is not much easier than remembering to delete things. It's trading one issue for another.
And now there's two ways to remember to manage memory.