Closed HertzDevil closed 2 years ago
I just hit exactly the same problem with the qt bindings. The memory of allocated classes is freed but their destructors are not called. And because many Qt classes use the pimpl-idiom, this means they have an internal d
-pointer to some data and this data will be leaked. This is true even for simple classes like QBrush
(this is where the problem hit me because I used Qt::Brush in some paint_event causing the program to eat up all memory).
This is really a serious issue. However, it can probably be solved wrapping new instances of wrapped classes in some small template wrapper inheriting from gc_cleanup or so.
I created a simple implementation that seems to work, at least with the qt bindings.
Closing due to code added in #119
At no point during execution does Bindgen actually invoke the destructors of wrapped C++ instances;
UseGC
only ensures the instances use the GC heap, deletion is still performed by a rawGC_free
. Consider:Nothing happens, but if a clean-up function is supplied to the constructor:
Then
T::~T()
will be printed. Is this behaviour intentional? (To be fair, since Qt has its own ownership semantics, calling the destructors on returned wrappers would probably break it immediately.)