i was looking into the memory use of dconf-server today and i discovered that dbus keeps a chunk of memory allocated that is approximately equal to the largest message that it has received.
this is because the 'data' DBusString that is stored as part of the DBusMessageLoader has _dbus_string_delete() called on it after the DBusMessage has been extracted. _dbus_string_delete() makes no attempt to reclaim memory from the shrinking string.
seeing as it is possible to receive a 64MB message, this should be fixed.
if (_dbus_string_get_length(data) > 2048)
would avoid malloc churn for normal-size messages, though it probably doesn't matter.
in DBusString or in DBusMessageLoader?
In the loader. Having the string "self compact" might be wrong in some cases, and there's various code that assumes the string never spontaneously reallocs smaller (and thus that using previously-allocated space can't fail due to OOM)
There's some kind of function on dbus string that reallocs smaller to fit the current content already, I don't remember its exact semantics.
Created attachment 11290 [details] [review]
implement _dbus_string_compact() and use it
Looks good, thanks. I would take a couple minutes to add a test case for two code paths ("there was more than max_waste wasted" and "there wasn't"), in dbus-string-util.c:_dbus_string_test()
This is fine to commit otherwise. (don't remember if you have access, if you don't then it would be good to ask a fd.org admin to add you to the dbus group)
I think it is time for another development release. Get this into head and I will roll one. I'm guessing this should go into stable too?
this is fine for stable and devel, though I don't think it's critical for stable. hopefully we'll have a 1.2 relatively soon (not sure we should block on getting around to reviewing all those portability patches, though it sucks not to)
If you're rolling a release anyway you can probably just commit this for ryan if he has no account.
i'm waiting to be added to the group, but no point in waiting.
you can go ahead and do this without me.
committed to git