comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Drummond <brian_drummond@btconnect.com>
Subject: Re: Ada newbie  + Gtkada + Win2000 = ?
Date: Mon, 17 Sep 2007 00:54:30 +0100
Date: 2007-09-17T00:54:30+01:00	[thread overview]
Message-ID: <1tdre3tgvbd015m2g8f648e800hre3dfk3@4ax.com> (raw)
In-Reply-To: 17yxr4b662tt9$.1ki8b1ck4hreq.dlg@40tude.net

On Sun, 16 Sep 2007 16:53:54 +0200, "Dmitry A. Kazakov"
<mailbox@dmitry-kazakov.de> wrote:

>On Sun, 16 Sep 2007 15:11:06 +0100, Brian Drummond wrote:
>
>> There are two mysteries here: - why the memory leaks occur; the GTK
>> documentation claims it manages memory for you, and why it falls over so
>> early (even when there is about 500MB of free memory) - if there is some
>> heap limit imposed on the program, I can't see it.
>
>Well, GTK does not manage memory. Though, it has a reference counting model
>for its objects, it does not provide handles to. The counts need to be
>managed manually using Ref, Unref, Sink and Destroy. GtkAda is a thin
>binding to GTK+, so it just follows this [IMO, flawed] design.
>
>In effect, when you call Gtk_New the result of is a plain pointer. It is
>your responsibility to pass it back to a container type or else explicitly
>kill the object. Note also as if that was not enough complicated, GTK has
>widgets and other objects. When created both have the reference count 1.
>But then for objects you do:
>
>1. put it into a GTK container (the count is now 2)
>2. Unref (the count is 1 and the container holds the object)

Thanks, that gives me a few things to look at.
But so far, it looks like unref'ing anything that is GTK_New'ed from
user code (i.e. the "testgtk" sources) results in releasing important
objects; I believe I have to dig into GTK or GDK to find the problem.

As you say, the problem seems to be getting handles to the things you
need to free.

>Sources are available at:
I found some (presumably the correct vintage) on libre; haven't tried
them yet. Next weekend probably.

>For debugging reference counts you can use the Ref_Count function from:
>
>http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#10.2

Thanks!

- Brian



  reply	other threads:[~2007-09-16 23:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-16 14:11 Ada newbie + Gtkada + Win2000 = ? Brian Drummond
2007-09-16 14:53 ` Dmitry A. Kazakov
2007-09-16 23:54   ` Brian Drummond [this message]
2007-09-16 18:12 ` michael bode
replies disabled

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