Re: Factories, handles, and handle wrappers
On 17/12/09 21:42, Paavo Helde wrote:
Maxim Yegorushkin<maxim.yegorushkin@gmail.com> wrote in
news:4b2a898e$0$9753$6e1ede2f@read.cnntp.org:
It is interesting that you mention non-deterministic destruction and
leaks due to cycles with regards to one subject. To me it looks like
leaks due to cycles are an inherent problem of precisely deterministic
destruction, when some form of reference counting is used. For
example, Perl and Python use deterministic destruction and in these
languages leaks are possible due to cycles.
I have not (yet) used Python, but they claim to garbage-collect cycles as
of version 2.0:
http://docs.python.org/whatsnew/2.0.html#garbage-collection-of-cycles
This also means non-deterministic destruction, I guess.
Non-deterministic only when there are cycles though, I would guess.
I remember there was a long thread about garbage collection in C++ and IIRC
the outcome was that the garbage collector should release the memory, but
should not invoke any destructors, in order to avoid non-deterministic
behavior (postponing the destructor call forever is considered
deterministic).
It probably depends on one's definition of deterministic.
I think the major source of determinism in C++ is the scoped resource
management based on destructors (RAII). IMO, it is more powerful and
general mechanism applicable to pretty much any type of resource
(memory, mutexes, locks, connections, etc..) rather than garbage
collection limited to one type of resource which is memory and a
ridiculous prehistoric try/finally construct for anything else.
--
Max