Re: checking for memory leaks in gtk



On Wed, May 14, 2008 at 4:46 PM,  <jcupitt gmail com> wrote:
> 2008/5/14 Harinandan S <harinandans gmail com>:
> >  I dont have any pixmaps or images in my sample application.
>
> You don't directly, but the theme engine you are using might. I tried
> your program under valgrind and it reports no leaks, so I imagine you
> are OK.

When i ran it under valgrind with G_SLICE=always-malloc G_DEBUG=gc_friendly\
valgrind --tool=memcheck --leak-check=yes ./a.out &>leak.log

I got these leaks reported.

256 bytes in 1 blocks are possibly lost in loss record 87 of 150
==14218==    at 0x1B9053EE: realloc (vg_replace_malloc.c:197)
==14218==    by 0x1BF2DC9E: FcPatternObjectInsertElt (fcpat.c:357)
==14218==    by 0x1BF2E8D7: FcPatternObjectAddWithBinding (fcpat.c:514)
==14218==    by 0x1BF2ECD2: FcPatternObjectAdd (fcpat.c:544)
==14218==
==14218==
==14218== 800 bytes in 20 blocks are possibly lost in loss record 116 of 150
==14218==    at 0x1B905301: calloc (vg_replace_malloc.c:176)
==14218==    by 0x1C0297C3: IA__g_malloc0 (gmem.c:150)
==14218==    by 0x1BFDB4F3: type_node_any_new_W (gtype.c:342)
==14218==    by 0x1BFDB580: type_node_fundamental_new_W (gtype.c:447)
==14218==
==14218==
==14218== 4864 bytes in 19 blocks are definitely lost in loss record 141 of 150
==14218==    at 0x1B9053EE: realloc (vg_replace_malloc.c:197)
==14218==    by 0x1BF2DC9E: FcPatternObjectInsertElt (fcpat.c:357)
==14218==    by 0x1BF2E8D7: FcPatternObjectAddWithBinding (fcpat.c:514)
==14218==    by 0x1BF2ECD2: FcPatternObjectAdd (fcpat.c:544)
==14218==
==14218== LEAK SUMMARY:
==14218==    definitely lost: 4864 bytes in 19 blocks.
==14218==    possibly lost:   1056 bytes in 21 blocks.
==14218==    still reachable: 286841 bytes in 6743 blocks.
==14218==         suppressed: 200 bytes in 1 blocks.

My main concern is running this on DirectFB platform. Its accumulating
memory completely. I see no decrease in memory usage when second
window is destroyed.


>I don't have a directfb install or a windows machine handy
> though, so I can't test there.
>
> >  Am i calling the correct APIs? Help is greatly appreciated. Somehow i
> >  feel destroy is not happening properly!
>
> I think you're OK. I'd change a few things on style grounds though:
>
> void
> on_close_clicked (GtkButton * button, gpointer user_data)
> {
>  GtkWidget *window = GTK_WIDGET (user_data);
>
>  gtk_widget_destroy (window);
> }
>
> I'd use a GTK_WIDGET() cast here, it'll check the pointer for you, much safer.
>
> You shouldn't use gtkfixed unless you REALLY have to. gtk has a large
> set of layout widgets that can do all this for you automatically and
> attractively. As a bonus, when someone translates your application and
> the sizes of all the text strings changes, you won't need to
> reposition everything.




>
> gtk_button_new_with_mnemonic () is a strange one to use, that's really
> for menus. gtk_button_new_from_stock () might be better.
>
> John
>



-- 
Regards,
Harinandan S


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