News for hackers. Stuff that matters.
Re:Friendship ended with the garbage collector by JoeAltmaier on Friday August 27, 2021 @11:39AM (#28329215)
That's all fine for locals. How about members of objects? The object may be long-lived, the buffer it uses may be short-lived, and it can hang around unless you remember to null it.

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.

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.