Array-Size

Thiago Macieira thiago.macieira at trolltech.com
Wed Apr 5 03:40:03 PDT 2006


staneker at gris.uni-tuebingen.de wrote:
>> > ==7961== LEAK SUMMARY:
>> > ==7961==    definitely lost: 302 bytes in 16 blocks.
>> > ==7961==      possibly lost: 130 bytes in 4 blocks.
>> > ==7961==    still reachable: 100,671,104 bytes in 59 blocks.
>> > ==7961==         suppressed: 0 bytes in 0 blocks.
>> >
>> > Still reachable is about 100MB?!? Does dbus internally copy
>> > the array twice?
>>
>> dbus will copy it into the DBusMessage. That should be all though.
>
>uh. is there an important reason, why dbus copies the data?

You don't know if the pointer that was passed will live long enough. The 
transmission may take some time -- especially for a large array. When the 
kernel-side buffers fill up, dbus will probably yield control back to the 
application, to avoid a GUI freeze.

The problem is that this requires the array data to remain valid for the 
duration of the transmission. We can't guarantee that with a simple 
pointer.

The other possibility is to transfer control of the array to libdbus, 
allowing it to free (or not) the pointer when it's done using it.

>Ok, but I think this is not necessary if you are using only
>C-arrays (vectors)...

As I said, you have to make sure the data remains valid for the duration 
of the processing. In fact, you have to make sure the data remains valid 
for the lifetime of the DBusMessage object.

-- 
Thiago José Macieira - thiago.macieira AT trolltech.com
Trolltech AS - Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20060405/4e0bba79/attachment.pgp


More information about the dbus mailing list