RE: Size of application is huge
- From: "Andersen, Jan" <jandersen informatica com>
- To: "Gus Koppel" <gtk spamkiller bytechase cx>, <gtk-app-devel-list gnome org>
- Subject: RE: Size of application is huge
- Date: Fri, 6 Aug 2004 16:39:42 +0100
Thanks for your good advice. I had already done part of this before I wrote to the list, but I am going to
dig deeper into it next week. What I have seen so far is that immediately after the step in the program where
I create/display etc a notebook, the program grows about 8MB; this is before I add anything to the notebook.
I find it hard to imagine what I should have done differently from what I have done.
I have put the code on display on http://www.talentex.demon.co.uk/index.html - this is just a web page with a
single link to the tar file. It ought to build with a ./configure and make, and there's a parameter file in a
horrible format called rd.cfg - specify that on the command line, other wise the program looks for it in /etc.
I really hope to resolve this issue - it is great fun to use GTK.
From: Gus Koppel [mailto:gtk spamkiller bytechase cx]
Sent: Fri 06-Aug-04 23:22
To: gtk-app-devel-list gnome org
Subject: Re: Size of application is huge
"Andersen, Jan" wrote:
I have made a simple (simplish) application: it reads a configuration
and based on this it creates an information display. The information
is organized thus:
- The toplevel is a notebook with a number of tabs.
- Each tab contains another notebook with a number of tabs
- Each tab in those notebooks contains a GtkTreeView displaying a
GtkListStore with up to <100 lines of text.
The toplevel notebook typically has 8 pages and each second level
notebook has 4 pages.what shocks me is the fact that it uses about
318MB from start. Another problem is that after several hours of use
it will sometimes allocate everything in the machine (up to 1.5GB -
all real and virtual storage), then it will dump it all as a core
Is it reasonable that this construction uses 318MB?
No, it is not. I understood you have roughly 8 pages * 4 pages * 100
treeview_lines. I don't think a compilation misconfiguration can cause
that huge memory consumption. Since there are many other applications
around which make use of multiple notebook pages and treeviews without
such high memory consumptions, and since it is not unusual for non-
expert GTK programmers to overlook some of the many traps in resource
management, I'd strongly believe you have some sort of serious resource
leak in your program indeed.
You should gradually try the following:
1. disable your information display code (don't fill the treeviews).
2. don't read the configuration (file?) at all.
3. disable all your own signal handlers and their connections.
4. revert entirely to the raw output as produced by Glade and run it.
Disabling refers to turning the respective code lines into comments. Try
these steps, go on disabling your own code pieces and test the memory
consumption of your running application again and again. Likely at some
point (I'd expect 3.) you'll find that your application doesn't use that
much RAM any more. If so, you would have to examine your handlers
against improper use of resources. Possibly you fail to free temporary
resources while filling your treeviews with content.
Basically, try to free every object you've been using or refering to. If
you mistakenly free something too early or too much your application
will probably quickly start crashing at some point. If you fail to free
resources your application usually won't crash but more or less quickly
consume more and more resources as it runs. In my opinion the former
case is slightly easier to debug.
As a last resort try to run the raw C program, as created by Glade
according to your window and dialog definitions, on its own, without any
of your custom code. Make your multiple-tabs window auto-open in Glade.
Nested notebooks and multiple treeviews should be created and appear,
just the treeviews would stay empty. Finally, at this stage your
"application" should consume probably less than 10 MB of RAM. Otherwise
you'd suffer from a serious system malady indeed.
The other problem is probably because I do something wildly stupid
somewhere, I'll catch that eventually, but if GNOME is that wasteful
with its memory, I'd better find another tool.
Generally GTK+ isn't. The Gnome desktop environment as a whole may be a
different story, but that story is similar among most other desktop
environments as well.
Btw, to briefly clarify:
Gnome == desktop environment, consisting of numerous applications,
applets, window manager and style guides for applications.
GTK+ == toolkit library to write graphical applications with, no matter
whether they do or don't belong to Gnome. Gnome apps use GTK+ library.
Glade == tool to design the framework of GTK+ based applications.
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
] [Thread Prev