| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>Debugging reference count problems: GObject Reference Manual</title> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> |
| <link rel="home" href="index.html" title="GObject Reference Manual"> |
| <link rel="up" href="pt03.html" title="Part V. Related Tools"> |
| <link rel="prev" href="tools-ginspector.html" title="Graphical inspection of GObjects"> |
| <link rel="next" href="tools-gtkdoc.html" title="Writing API docs"> |
| <meta name="generator" content="GTK-Doc V1.25.1 (XML mode)"> |
| <link rel="stylesheet" href="style.css" type="text/css"> |
| </head> |
| <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle"> |
| <td width="100%" align="left" class="shortcuts"></td> |
| <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td> |
| <td><a accesskey="u" href="pt03.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td> |
| <td><a accesskey="p" href="tools-ginspector.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td> |
| <td><a accesskey="n" href="tools-gtkdoc.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td> |
| </tr></table> |
| <div class="chapter"> |
| <div class="titlepage"><div><div><h2 class="title"> |
| <a name="tools-refdb"></a>Debugging reference count problems</h2></div></div></div> |
| <p> |
| The reference counting scheme used by GObject does solve quite |
| a few memory management problems but also introduces new sources of bugs. |
| In large applications, finding the exact spot where the reference count |
| of an Object is not properly handled can be very difficult. |
| </p> |
| <p> |
| A useful tool in debugging reference counting problems is to |
| set breakpoints in gdb on g_object_ref() and g_object_unref(). |
| Once you know the address of the object you are interested in, |
| you can make the breakpoints conditional: |
| </p> |
| <pre class="programlisting"> |
| break g_object_ref if _object == 0xcafebabe |
| break g_object_unref if _object == 0xcafebabe |
| </pre> |
| <p> |
| </p> |
| </div> |
| <div class="footer"> |
| <hr>Generated by GTK-Doc V1.25.1</div> |
| </body> |
| </html> |