qt-interest@trolltech.com
[Top] [All Lists]

Re: Qt and garbage collection

Subject: Re: Qt and garbage collection
From: Achilleas Margaritis
Date: Tue, 25 Dec 2007 21:01:29 +0200
I've just managed to compile Qt with Boehm's gc. It's perfect. I run all the demos, and there was no problem.

No more memory leaks for me, no need to worry about cycles, no need to use other languages than c++ and Qt.

Happy new year to everyone!

O/H Paul Miller έγραψε:
Achilleas Margaritis wrote:
Reference counted pointers take up a few dozen cycles to execute their operations, where as raw pointers take a few cycles.

Good ones have one extra pointer indirection - same as a virtual function call.

But aside from that (in this day and age, performance is not the main problem), what about programmer performance?

I am about to write a big application, the contractor insists on using C++, the deadline is 3 months, and the penalties for delay are severe.

What choices do I have? reference counting will only solve some problems, but I can't do it without thinking about memory management...and having to think about memory management will add at least 30% development time.

You mention programmer performance. I use boost intrusive reference-counted pointers for most items in my object models, and almost never "think" about memory management. Maybe, since I've been doing this for so long, I'm just used to it. And, I can actually "know" when my memory is getting cleaned up, which is useful in high-performance graphics software.

I just think you're undervaluing reference-counting. The "problems" with them are very few (or non-existent) to me.


Qt is so nice...if only it had garbage collection!


O/H Paul Miller έγραψε:
Achilleas Margaritis wrote:
Hello everyone.

Isn't it time for Qt (the best library out there), to have garbage
collection? Boehm's gc is mature software and it exists for all major
platforms.

Qt's memory management pattern (ownership of objects) is not enough when
 objects are used in complex ways. Furthermore, lots of Qt classes do
not inherit from QObject, making them difficult to be used with manual
memory management.

Reference counting is not the appropriate solution for memory
management, because a) it does not handle cycles (and Qt objects have
quite a lot of thme), b) it hurts performance.

You seem to buying into a lot of myths about reference counting. Have you collected much data that shows that Qt's memory management is adversely affecting your application performance?

I've been using reference-counting in my own commercial applications for over a decade - some of them real-time graphics applications, and never felt that reference-counting was impairing performance. And with some careful design, a cyclic reference pattern has NEVER come up.


--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/





--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>