comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Link gnat with "purify" to try to find a memory leak
Date: Mon, 29 Sep 2008 09:36:06 +0200
Date: 2008-09-29T09:36:06+02:00	[thread overview]
Message-ID: <i98ri4nh3oa8.1ls6j36uu1v8q$.dlg@40tude.net> (raw)
In-Reply-To: 0a839a05-adfc-4669-b0b5-47ae3c15b238@s50g2000hsb.googlegroups.com

On Sun, 28 Sep 2008 15:43:35 -0700 (PDT), FJCS_Montecoruto wrote:

> A "memory leak" has been detected in one of our Gnat-Ada/GtkAda
> executables. I was directed with others to try to find where exactly
> is it located in our code.
> 
> Is it possible to somehow use "Rational Purify", to link it with our
> Gnat-Ada/GtkAda objects, and so generate some instrumentalized
> executable to run and test it under "Purify" ?.
> 
> If so, is there an "easy way" to be able to do it ?. We have tried,
> but we have had a hard time linking the objects.

There is no easy way, but the starting point should be to review all
Gtk_New calls. Especially ones of initially owned objects. Differently to
floating objects, these require Unref called after the object is placed
into a container. Descendants of Gtk_Object are floating. Non-widgets are
usually owned. Missing Unref causes a leak.

Print the reference counts of suspicious objects. An object in the
container must have the count 1.

GtkAda contributions provides function Ref_Count that returns GTK's
reference count of an object. See

http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#10.3

For tracing a GTK application you can use the procedure Trace defined in
Gtk.Main.Router. For example:

with Gtk.Main.Router;  use Gtk.Main.Router;
with GLib.Object.Ref_Count;

...
   Gtk.Main.Init;
   Gtk.Main.Router.Init; -- Before entering the main loop
...
   Trace ("Ref count" & GUInt'Image (GLib.Object.Ref_Count (Object));
...

See http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#1.2

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2008-09-29  7:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-28 22:43 Link gnat with "purify" to try to find a memory leak FJCS_Montecoruto
2008-09-29  0:32 ` Jeffrey R. Carter
2008-09-29  7:36 ` Dmitry A. Kazakov [this message]
2008-09-29  8:32 ` xavier grave
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox