1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Debugging reference count problems</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GObject Reference Manual">
8 <link rel="up" href="pt03.html" title="Part V. Related Tools">
9 <link rel="prev" href="tools-ginspector.html" title="Graphical inspection of GObjects">
10 <link rel="next" href="tools-gtkdoc.html" title="Writing API docs">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16 <td><a accesskey="p" href="tools-ginspector.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17 <td><a accesskey="u" href="pt03.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19 <th width="100%" align="center">GObject Reference Manual</th>
20 <td><a accesskey="n" href="tools-gtkdoc.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
23 <div class="titlepage"><div><div><h2 class="title">
24 <a name="tools-refdb"></a>Debugging reference count problems</h2></div></div></div>
26 The reference counting scheme used by GObject does solve quite
27 a few memory management problems but also introduces new sources of bugs.
28 In large applications, finding the exact spot where the reference count
29 of an Object is not properly handled can be very difficult. Hopefully,
30 there exist a tool named <a class="ulink" href="http://refdbg.sf.net/" target="_top">refdbg</a>
31 which can be used to automate the task of tracking down the location
32 of invalid code with regard to reference counting. This application
33 intercepts the reference counting calls and tries to detect invalid behavior.
34 It supports a filter-rule mechanism to let you trace only the objects you are
35 interested in and it can be used together with GDB.
39 Note that if GObject has been compiled with <code class="option">--enable-debug=yes</code>,
40 it exports a trap variable
42 <pre class="programlisting">
43 static volatile GObject *g_trap_object_ref;
46 If set to a non-NULL value, <a class="link" href="gobject-The-Base-Object-Type.html#g-object-ref" title="g_object_ref ()">g_object_ref</a>()
47 and <a class="link" href="gobject-The-Base-Object-Type.html#g-object-unref" title="g_object_unref ()">g_object_unref</a>() will be intercepted
48 when called with that value.
53 Generated by GTK-Doc V1.18</div>