The Contacts mixin wastes memory in duplicated strings
Submitted by Alban Crequy
Assigned to Telepathy bugs list
Description
Valgrind-massif shows the following usage of the heap in gabble:
->10.27% (643,386B) 0x47C0209: standard_malloc (gmem.c:88) | ->10.26% (642,747B) 0x47C0750: g_malloc (gmem.c:164) | | ->05.11% (320,171B) 0x47D88C9: g_strdup (gstrfuncs.c:102) | | | ->01.74% (108,836B) 0x44660C2: tp_contacts_mixin_set_contact_attribute (in /usr/lib/libtelepathy-glib.so.0.61.0) | | | | ->00.38% (23,760B) 0x8135A65: conn_client_types_fill_contact_attributes (conn-client-types.c:165) | | | | | ->00.38% (23,760B) 0x4465D32: tp_contacts_mixin_get_contact_attributes (in /usr/lib/libtelepathy-glib.so.0.61.0)
In my tests, I have 330 contacts.
It means the string "org.freedesktop.Telepathy.Connection.Interface.ClientTypes/client-types" uses 23kbytes of memory.
The string "org.freedesktop.Telepathy.Connection.Interface.ContactCapabilities/capabilities" also uses 23kbytes of memory.
In total, tp_contacts_mixin_set_contact_attribute() is responsible for 108kbytes of memory, most of it is just a few strings strdup'ed for each contact.
Could GQuarks be used instead of duplicating strings?
Version: git master