RE: Memory leak in gdbus-codegen generated code



On Tue, 2015-02-10 at 08:45 +0000, Norman, Anders wrote:
From: Tristan Van Berkom [mailto:tristan upstairslabs com]
Sent: 10. februar 2015 08:25
To: Norman, Anders
Cc: gtk-list gnome org
Subject: RE: Memory leak in gdbus-codegen generated code

On Tue, 2015-02-10 at 06:59 +0000, Norman, Anders wrote:
Well, I consider it a leak and need it cleaned up.


Yes, some people stubbornly think that, however it's entirely unfounded.

In languages with OO features built in, the data attached to a type
definition (a class) is loaded with the binary generally, in C there is
no such thing, so this data which defines a type is initialized
once-off, the first time you register a type.
I'm quite new to glib/gdbus, but I would presume that if I instanciate two skeletons of the same class, the 
signal instances are different. Hence, the signals are instance/object data and not class data.


Not at all, the memory allocated by g_signal_new() belongs to the class,
you can create as many instances of a the given class and g_signal_new()
will only be called once.

This particular case is a little different, though, because this is an
interface initializer, in this case, it will be called once for every
*first* instantiation of any class which implements that interface (in
the dbus case, it can be called once for the skeleton, and once for the
proxy).

Were it to be leaking memory from g_signal_connect(), this would indeed
indicate an instance level leakage.

Best Regards,
    -Tristan

PS: I hope this message was not sent twice, as I canceled the first
sending of this message.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]