More memory stuff with some interesting output




Ok, I claimed that glib was lying to me, I also claimed that I was having 
memory problems that I couldn't sort out.  Here is a snippet of code, 
and the output of g_mem_profile, maybe this will point out what the problem
is, (possibly something wrong with gtk+?  Usually that's the last thing I 
would assume as I have been known to make mistakes just like everybody else)

Vital statistics about me (All the results of rpm -q's):
gtk+-1.2.3-1
glib-1.2.3-1
egcs-1.1.2-12
glibc-2.1.1-6
XFree86-libs-3.3.3.1-52

The code snippet....

<CODE>
fprintf(Q,"Before gtk_init...\n");
g_mem_profile();

gtk_init(&argc, &argv);

g_mem_profile();

gtk_main_quit();
g_mem_profile();

gtk_exit(0);
</CODE>

The program does a few miscellaneous things before hand, (which are reflected
in the g_mem_profile right before gtk_init() and there is one outstanding 
variable which at that point SHOULD be outstanding)

I just added the gtk_main_quit right after gtk_init to prove this point - as
you can see, no widgets were made/destroyed in the code.

And the output:

<OUTPUT>
Before gtk_init...
GLib-INFO: 1 allocations of 22 bytes
GLib-INFO: 1 allocations of 23 bytes
GLib-INFO: 45 bytes allocated
GLib-INFO: 23 bytes freed
GLib-INFO: 22 bytes in use

(Comment - this is right AFTER gtk_init)
GLib-INFO: 2 allocations of 2 bytes
GLib-INFO: 9 allocations of 3 bytes
GLib-INFO: 238 allocations of 4 bytes
GLib-INFO: 19 allocations of 5 bytes
GLib-INFO: 15 allocations of 6 bytes
GLib-INFO: 21 allocations of 7 bytes
GLib-INFO: 337 allocations of 8 bytes
GLib-INFO: 22 allocations of 9 bytes
GLib-INFO: 33 allocations of 10 bytes
GLib-INFO: 8 allocations of 11 bytes
GLib-INFO: 116 allocations of 12 bytes
GLib-INFO: 14 allocations of 13 bytes
GLib-INFO: 4 allocations of 14 bytes
GLib-INFO: 8 allocations of 15 bytes
GLib-INFO: 110 allocations of 16 bytes
GLib-INFO: 9 allocations of 17 bytes
GLib-INFO: 1 allocations of 19 bytes
GLib-INFO: 6 allocations of 20 bytes
GLib-INFO: 6 allocations of 22 bytes
GLib-INFO: 1 allocations of 23 bytes
GLib-INFO: 18 allocations of 24 bytes
GLib-INFO: 25 allocations of 28 bytes
GLib-INFO: 3 allocations of 29 bytes
GLib-INFO: 1 allocations of 30 bytes
GLib-INFO: 50 allocations of 32 bytes
GLib-INFO: 3 allocations of 34 bytes
GLib-INFO: 2 allocations of 40 bytes
GLib-INFO: 3 allocations of 43 bytes
GLib-INFO: 13 allocations of 44 bytes
GLib-INFO: 1 allocations of 47 bytes
GLib-INFO: 10 allocations of 52 bytes
GLib-INFO: 1 allocations of 60 bytes
GLib-INFO: 36 allocations of 64 bytes
GLib-INFO: 1 allocations of 68 bytes
GLib-INFO: 3 allocations of 92 bytes
GLib-INFO: 1 allocations of 94 bytes
GLib-INFO: 3 allocations of 128 bytes
GLib-INFO: 1 allocations of 148 bytes
GLib-INFO: 13 allocations of 304 bytes
GLib-INFO: 2 allocations of 512 bytes
GLib-INFO: 1 allocations of 652 bytes
GLib-INFO: 7 allocations of 1024 bytes
GLib-INFO: 2 allocations of 2048 bytes
GLib-INFO: 3 allocations of 4001 bytes
GLib-INFO: 3 allocations of 4096 bytes
GLib-INFO: 2 allocations of greater than 8191 bytes
GLib-INFO: 81976 bytes allocated
GLib-INFO: 39780 bytes freed
GLib-INFO: 42196 bytes in use

Gtk-CRITICAL **: file gtkmain.c: line 534 (gtk_main_quit): assertion `main_loops != NULL' failed.
(Comment - I'm guessing this happened because I cheated gtk out of getting
to deal with any signals and so on - normally it doesn't happen when I do
things between gtk_init and gtk_main_quit)

(Comment - this is right AFTER gtk_main_quit)
GLib-INFO: 2 allocations of 2 bytes
GLib-INFO: 9 allocations of 3 bytes
GLib-INFO: 238 allocations of 4 bytes
GLib-INFO: 19 allocations of 5 bytes
GLib-INFO: 15 allocations of 6 bytes
GLib-INFO: 21 allocations of 7 bytes
GLib-INFO: 337 allocations of 8 bytes
GLib-INFO: 22 allocations of 9 bytes
GLib-INFO: 33 allocations of 10 bytes
GLib-INFO: 8 allocations of 11 bytes
GLib-INFO: 116 allocations of 12 bytes
GLib-INFO: 14 allocations of 13 bytes
GLib-INFO: 4 allocations of 14 bytes
GLib-INFO: 8 allocations of 15 bytes
GLib-INFO: 110 allocations of 16 bytes
GLib-INFO: 9 allocations of 17 bytes
GLib-INFO: 1 allocations of 19 bytes
GLib-INFO: 6 allocations of 20 bytes
GLib-INFO: 6 allocations of 22 bytes
GLib-INFO: 1 allocations of 23 bytes
GLib-INFO: 18 allocations of 24 bytes
GLib-INFO: 25 allocations of 28 bytes
GLib-INFO: 3 allocations of 29 bytes
GLib-INFO: 1 allocations of 30 bytes
GLib-INFO: 50 allocations of 32 bytes
GLib-INFO: 3 allocations of 34 bytes
GLib-INFO: 2 allocations of 40 bytes
GLib-INFO: 3 allocations of 43 bytes
GLib-INFO: 13 allocations of 44 bytes
GLib-INFO: 1 allocations of 47 bytes
GLib-INFO: 10 allocations of 52 bytes
GLib-INFO: 1 allocations of 60 bytes
GLib-INFO: 36 allocations of 64 bytes
GLib-INFO: 1 allocations of 68 bytes
GLib-INFO: 3 allocations of 92 bytes
GLib-INFO: 1 allocations of 94 bytes
GLib-INFO: 3 allocations of 128 bytes
GLib-INFO: 1 allocations of 148 bytes
GLib-INFO: 13 allocations of 304 bytes
GLib-INFO: 2 allocations of 512 bytes
GLib-INFO: 1 allocations of 652 bytes
GLib-INFO: 7 allocations of 1024 bytes
GLib-INFO: 2 allocations of 2048 bytes
GLib-INFO: 3 allocations of 4001 bytes
GLib-INFO: 3 allocations of 4096 bytes
GLib-INFO: 2 allocations of greater than 8191 bytes
GLib-INFO: 81976 bytes allocated
GLib-INFO: 39780 bytes freed
GLib-INFO: 42196 bytes in use

(Comment:  gtk_exit(0) gets called)
</OUTPUT>


ca 42k of unfreed memory???  When I run the whole application without just
making it take a dive right after it starts up like I did above, it ends up
with 300k unfreed memory.  Some of that may be me, but I've checked through
many times, and I'm thinking most of it is gtk+
-- 
David Allen
http://opop.nols.com/
----------------------------------------
Dessert is probably the most important stage of the meal, since it will 
be the last thing your guests remember before they pass out all over 
the table. 
- The Anarchist Cookbook 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]