Re: memory leak in GtkListStore?



yes, I allready done this but valgrind reports some leaks in the gtk
libraries not in my code.

 I thaught I fill in the wrong way the list store, thats way I ask here
about it.

Thijs Assies wrote:

> 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.
>

--
Razvan
razvaneduard xnet ro





-------------------------------------------------------
Xnet scaneaza automat toate mesajele impotriva virusilor folosind RAV AntiVirus.
Xnet automatically scans all messages for viruses using RAV AntiVirus.

Nota: RAV AntiVirus poate sa nu detecteze toti virusii noi sau toate variantele lor. Va rugam sa luati in 
considerare ca exista un risc de fiecare data cand deschideti fisiere atasate si ca MobiFon nu este 
responsabila pentru nici un prejudiciu cauzat de virusi.
Disclaimer: RAV AntiVirus may not be able to detect all new viruses and variants. Please be aware that there 
is a risk involved whenever opening e-mail attachments to your computer and that MobiFon is not responsible 
for any damages caused by viruses.




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