Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, February 2008
Re: Problems with deferred deletion of objects in 4.4 beta


Message 1 in thread

Joe Newman wrote:
> We're seeing significant memory leaks with 4.4 beta, and I
> think I've found the reason why.
[snip]
> 
> Does this mean we no longer need to clean up when our application shuts
> down by calling qApp->processEvents(QEventLoop::DeferredDeletion)?

DeferredDelete event handling has been improved to the point where most manual
deliver of such events is unnecessary[1]. As such, the DeferredDeletion
processEvents() flag has been deprecated and doesn't work anymore in 4.4. In
addition, it's just another way of calling sendPostedEvents(0,
QEvent::DeferredDelete); However, a gratuitous change like that isn't
necessarily a good thing. I'll fix it so that the flag continues to work.

[1] However, if you call deleteLater() on many objects after the event loop
has been stopped, it's still necessary to manual clean them up (as you
apparently do).

> If so, why are we getting so many leaked objects with 4.4 beta?  Shouldn't they
> get cleaned up automatically if they've been flagged for deferred
> deletion?

If you replace qApp->processEvents(QEventLoop::DeferredDeletion) with
QApplication::sendPostedEvents(0, QEvent::DeferredDelete), does the leak go
away? If so, my revert of the QEventLoop::DeferredDeletion crippling will fix
your problem.

-- 
 [ signature omitted ]