Originally Posted by grumpy
Simply?
Given the number of times this sort of problem catches out both novices and experts, I would hardly describe it as "simple".
In a very small program that might be easy. As the program gets larger, it becomes more challenging to manage object lifetime. In a program of moderate size (by which I mean less than a man year to develop) it is not so easy. In a large program (developed by a team, and several man years of effort involved) it takes quite a bit of effort to ensure that all objects are cleaned, and error prone checks are either eliminated or corrected.