[Development] Qt's Leak-on-exit policy

Tim Blechmann tim at klingt.org
Thu Dec 19 11:29:36 CET 2013


>> In QtQuick, QSGRenderLoop::instance() can create a QSGWindowsRenderLoop
>> using new that it never destroys. The memory is always pointed to by a
>> static member pointer, so it's never "lost" exactly, but the memory is
>> never freed by Qt (but hopefully will be by any decent OS). Is this a bug?
>> Should Qt libs bother freeing memory on exit, or is this an unnecessary
>> expense?
> 
>> Should Qt clean-up dynamically allocated reachable pointers, or is this
>> useless / pointless work?
[snip]
> 2) static leak, which is when the pointer is overwritten at shutdown without 
> being freed

i wonder: what is the definition of "shutdown"?

in many applications it is perfectly fine to allocate memory without
freeing them ...

however there are use cases, in which "shutdown" and "termination" are
two different things, mainly when dynamically loading/unloading a
library: when unloading a library the destructors inside this library
will be called, but the application itself isn't terminated. in these
cases 'static leaks' do matter

cheers,
tim




More information about the Development mailing list