Re: memory leak in GtkListStore?



Razvan wrote:

I fill a GtkListStore with 300000 rows and then clear the list store, and this for many times, to check if I forget some pointers in memory.

And 'top' show me that some allocated momory remain nealocated, because memory alocated for my program grows.

GtkTreeIter is allocatred on the stack and is don't need to be free()d.

Perhaps is something I miss, I don't know...

Same thing happens if I fill a GtkTextBuffer with 10000 lines, then delete them, then fill again and so on...

If anyone have some ideas I will apreciate

Thanks

this is the code

#include <glib.h>
#include <gtk/gtk.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

GtkListStore *store;

int main(int argc, char **argv){
    gtk_init(&argc,&argv);

store=gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING ); GtkTreeIter iter; int j;
    for(j=0;j<100;j++){
        printf("begin fill liststore\n");
        int i;
        for(i=0;i<300000;i++){
            gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,0,"some string",1,"other string",2,"yet another",-1);
        }
// golire
        printf("delete lines\n");
        gtk_list_store_clear(store);
        printf("lines deleted\n");
    }
    return 1;
}





you should download valgrind. en start your program using: valgrind --leak-check=yes ./program make sure you compiled your program with -g3 and when the program exits, valgrind tells you where there is a memory leak, wich file, wich line.






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