David White <[email protected]>:
> Realistically, Python can have memory leaks: if you no longer use an
> object, but forget to kill a variable that refers to it, in practice
> that is a leak.

Hm.  It would have to be a global.  Python method and function and
method locals will free the last reference when the defining scope is
exited.
 
> It might not happen as often as memory leaks in a C program, but I think
> it will happen *more* often than memory leaks do using the C++ RAII
> approach we use on Wesnoth. We have had very few problems with memory
> leaks in Wesnoth's history.

Because Python locals effectively die when they go out of scope, and 
garbage collecting is done by reference count, I think the Python way
is essentially equivalent to RAII.

Caveat: *only in C-Python*. JPython uses the Java garbage collector
and thus does not have deterministic destructor timing.  I think I
explained this to you on IRC once.
-- 
                <a href="http://www.catb.org/~esr/";>Eric S. Raymond</a>

_______________________________________________
Wesnoth-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-dev

Reply via email to