Long ago and cubicle far, far away I wrote this little debugging
enhancement for GObject that collects statistics about instance
creation, destruction, etc. by class type and then prints a nicely
formatted report when piped through a tool named 'gobject-stats'.

My proposal for it got kinda hijacked and veered off into something even
fancier involving systemtap (it all kinda went over my head), so I don't
expect my patch to ever actually land in upstream GLib.

Nevertheless, I had occasion to wish for this feature again recently so
I dusted off my original patch and rebased it for GLib 2.28.

Here's the link (comment #46):
https://bugzilla.gnome.org/show_bug.cgi?id=354457#c45

Thought others might find it handy so I'm mentioning it.


How to use it:

1. Build GLib with debugging features enabled (--enable-debug).
   Unstable GLib releases turn debugging features on by default,
   stable releases turn debugging features off by default.

2. GOBJECT_DEBUG=types $MY_APPLICATION 2>&1 | gobject-stats

3. Do stuff in $MY_APPLICATION, then quit.

4. Read the stats to see how badly $MY_APPLICATION is leaking objects.


Here's a sample run I did on e-calendar-factory 2.91.92:

$ GOBJECT_DEBUG=types e-calendar-factory 2>&1 | gobject-stats

Instance Type                       Max Population  # Created  # Destroyed  # 
Leaked
----------------------------------  --------------  ---------  -----------  
--------
GParamBoolean                                   35         35            0      
  35
EGdbusCalViewStub                               30         30            0      
  30
GParamObject                                    27         27            0      
  27
GParamString                                    22         22            0      
  22
ECalBackendSExp                                 21         39           23      
  16
GParamEnum                                      16         16            0      
  16
ESourceGroup                                    16         16            4      
  12
GParamPointer                                   11         11            0      
  11
GParamUInt                                      11         11            0      
  11
GParamBoxed                                     10         10            0      
  10
ESource                                         16         16           10      
   6
EDataServerModule                                6          6            0      
   6
GParamInt                                        6          6            0      
   6
GParamFlags                                      5          5            0      
   5
ESourceList                                      4          4            1      
   3
GParamULong                                      3          3            0      
   3
GParamGType                                      2          2            0      
   2
GSimpleAsyncResult                               7        675          674      
   1
GDBusMessage                                     4        452          451      
   1
GSocket                                          2         13           12      
   1
GCancellable                                     2          8            7      
   1
GDBusAuth                                        1          2            1      
   1
GDBusConnection                                  1          2            1      
   1
GIOPConnection                                   2          2            1      
   1
GSocketInputStream                               1          2            1      
   1
GSocketOutputStream                              1          2            1      
   1
GUnixConnection                                  1          2            1      
   1
GUnixSocketAddress                               1          2            1      
   1
ECalBackendCalDAVEventsFactory                   1          1            0      
   1
ECalBackendCalDAVMemosFactory                    1          1            0      
   1
ECalBackendCalDAVTodosFactory                    1          1            0      
   1
ECalBackendContactsEventsFactory                 1          1            0      
   1
ECalBackendFileEventsFactory                     1          1            0      
   1
ECalBackendFileJournalFactory                    1          1            0      
   1
ECalBackendFileTodosFactory                      1          1            0      
   1
ECalBackendGroupwiseEventsFactory                1          1            0      
   1
ECalBackendGroupwiseJournalFactory               1          1            0      
   1
ECalBackendGroupwiseTodosFactory                 1          1            0      
   1
ECalBackendHttpEventsFactory                     1          1            0      
   1
ECalBackendHttpMemosFactory                      1          1            0      
   1
ECalBackendHttpTodosFactory                      1          1            0      
   1
ECalBackendWeatherEventsFactory                  1          1            0      
   1
EGdbusBookFactoryProxy                           1          1            0      
   1
GConfClient                                      1          1            0      
   1
GThreadedResolver                                1          1            0      
   1
ECalComponent                                  196        263          263      
   0
GDataOutputStream                                1        250          250      
   0
GMemoryOutputStream                              1        248          248      
   0
GDataInputStream                                 1        206          206      
   0
GMemoryInputStream                               1        204          204      
   0
GDBusMethodInvocation                            3        150          150      
   0
EDataCalView                                    10         30           30      
   0
GInetSocketAddress                               1         27           27      
   0
GInetAddress                                     4         19           19      
   0
GSocketClient                                    1         13           13      
   0
GTcpConnection                                   1         11           11      
   0
SoupAddressAddressEnumerator                     1         11           11      
   0
SoupConnection                                   1         11           11      
   0
SoupSocket                                       1         11           11      
   0
EDataCal                                         6          6            6      
   0
EGdbusCalStub                                    6          6            6      
   0
EList                                            6          6            6      
   0
SoupMessage                                      1          6            6      
   0
EIntervalTree                                    5          5            5      
   0
GCredentials                                     2          4            4      
   0
SoupAddress                                      3          3            3      
   0
ECalBackendCalDAV                                2          2            2      
   0
ECalBackendFileStore                             2          2            2      
   0
EFileCache                                       2          2            2      
   0
EProxy                                           2          2            2      
   0
GDBusAuthMechanismExternal                       1          2            2      
   0
GSocketAddressAddressEnumerator                  1          2            2      
   0
GUnixCredentialsMessage                          1          2            2      
   0
SoupAuthBasic                                    2          2            2      
   0
SoupAuthManagerNTLM                              2          2            2      
   0
SoupSessionSync                                  2          2            2      
   0
EBook                                            1          1            1      
   0
ECalBackendContacts                              1          1            1      
   0
ECalBackendFileEvents                            1          1            1      
   0
ECalBackendFileJournal                           1          1            1      
   0
ECalBackendFileTodos                             1          1            1      
   0
EDataCalFactory                                  1          1            1      
   0
EGdbusCalFactoryStub                             1          1            1      
   0
EOfflineListener                                 1          1            1      
   0
GIOPServer                                       1          1            1      
   0


_______________________________________________
evolution-hackers mailing list
evolution-hackers@gnome.org
To change your list options or unsubscribe, visit ...
http://mail.gnome.org/mailman/listinfo/evolution-hackers

Reply via email to