[Qt-interest] using QObject's for object-relational mapping system

Dmitry Teslenko dteslenko at gmail.com
Fri Jan 16 11:07:06 CET 2009


On Thu, Jan 15, 2009 at 13:31, Tony Rietwyk
<tony.rietwyk at rightsoft.com.au> wrote:
> Dmitry wrote:
>
>> Hi!
>> I'm considering to implement ORM based on qt object system; It
>> means storing collections of thousands (or more) of QObject
>> descendands
>> with Q_OBJECT and Q_PROPERTY macros and serialization/de- of
>> such objects
>> based on QMetaClassInfo/Property;
>> How could this solution be resource-intense and what magnitudes of
>> QObjects could I operate this way?
>
> Hi Dmitry,
>
> Resource-wise, it depends on how the objects are going to be used once they
> are loaded.
>
> I can't find the reference, but I recall someone saying on this list that
> QObject's are heavy-weight in terms of construction and destruction. So if
> the objects are fairly static (like Qt's widgets), then the performance hit
> is negligible in release configurations. But, if the objects are going to be
> used as temporaries for intensive calculations, then the overhead will
> noticeably slow things down.
>
> Memory-wise, it would be best to generate a million objects, using whatever
> features (signals, children, etc.) are expected. Then measure it with
> Valgrind.
>
> Note that Qt does NOT use QObject as the base for QGraphicsItems, and lots
> of other worker objects.

I've made such a test and here's results for curious ones: million
QObjects with few properties (int, double, QDateTime) objects
can be constructed, sorted and purged within 15 secs and it
would require ~200 MB memory in release mode.

In debug mode time is x2. Interestingly, memory usage is also x2.

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?



More information about the Qt-interest-old mailing list