D wrapper classes leak memory. Next steps?

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 30 21:38:48 PDT 2014


GtkD wraps all the objects in Gtk. In callbacks like "onDraw",
when they are called often, this creates heaps of tiny wrapper
objects around huge data from C libraries. Eventually system
memory is exhausted and the computer slows down and eats into
swap. So should we add a "run garbage collector" button to
every application to clean those up? Seems rather silly.

The GC should stick to its own memory and not try to manage
resources it doesn't understand. Reference counting applies to
external and system resources much better. To date neither the
language nor Phobos can ref count classes. And even with
library support it is not likely that it will get used widely,
because plain classes are so much easier (also on the eyes).

The extent of this is pretty huge. There are many D wrapper
libraries that build on classes and mimic what is available
for C++ or Python. Issues like this make D appear like a toy
language. How would one write a big desktop application when
a simple animation can exhaust system memory in seconds ?

-- 
Marco



More information about the Digitalmars-d mailing list