From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,cf8b802d278af5c9 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.germany.com!storethat.news.telefonica.de!telefonica.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ada newbie + Gtkada + Win2000 = ? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <6h8qe35tkcunqut5ufvjn299om46ku72uh@4ax.com> Date: Sun, 16 Sep 2007 16:53:54 +0200 Message-ID: <17yxr4b662tt9$.1ki8b1ck4hreq.dlg@40tude.net> NNTP-Posting-Date: 16 Sep 2007 16:52:57 CEST NNTP-Posting-Host: f1c3f708.newsspool2.arcor-online.net X-Trace: DXC=h1DaAhW058O02Sh8E_NfIAA9EHlD;3YcB4Fo<]lROoRA<`=YMgDjhgB 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) for widgets 1. put into a container (the count is still 1, but the widget is no more "floating," it is owned) 2. do nothing It is very easy to mess with this. I guess that this is what caused leaking in the example you are talking about. > The memory leaks are concerning; it doesn't look to me as if there is a > solution at the Ada level, and the point of the exercise is to escape > from C, if possible. If I need to get the full set of GTK sources, build > them and debug, I might, but it'll take a lot longer... Sources are available at: http://www.gtk.org/ You have to take somewhat outdated ones, because GtkAda lags behind. For debugging reference counts you can use the Ref_Count function from: http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#10.2 -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de