In article
<ea511b08-c391-4c33-85ac-9c8fb2df62cd@t13g2000yqm.googlegroups.com>,
James Kanze <james.kanze@gmail.com> wrote:
On Oct 26, 7:12 pm, Leigh Johnston <le...@i42.co.uk> wrote:
On 26/10/2010 18:58, ?? Tiib wrote:
[...]
I replied else-thread that certain resources (of which memory can
be considered one) may be suitable for non-deterministic
releasing. C++ and RAII is superiour to C++ and garbage
collection; this is my opinion of course and (hopefully) the
opinion of others here too.
And C++ with RAII *and* garbage collection is superior to
either. Why limit your options? (If all you have is a hammer,
everything looks like a nail. It's best to have many different
tools in your toolbox, so you can use the most appropriate.)
The problem is that garbage collection essentially breaks RAII.
With RAII, all resources are treated the same regardless of if they
are memory or file handle or sockets or whatever. Designing with
RAII, your destructor will take care of closing files or freeing
memory, everything works fine. RAII is absolutely reliable. As
long
as all resources are owned by objects and all objects are destroyed,
no resources will ever be leaked.
Right. And if the only resources you ever use is memory, GC will take
care of that.