[gtkada] Clist and Chars_ptr_array

Preben Randhol randhol at pvv.org
Thu Nov 15 13:37:06 CET 2001


Emmanuel Briot <briot at ACT-Europe.FR> wrote on 15/11/2001 (11:58) :
> Preben Randhol <randhol at pvv.org> writes:
> 
> > I tried without the Free and saw that it leaked memory. But is the data
> > passed to the Clist removed in the sense Freed when you call Clear?
> 
> 
> Yes, I think so.
> gtk+ does a copy of the strings you pass, and frees the memory correctly every
> time a row is deleted or the contents of a cell changes.
> Same when you clear the whole list, since basically is deletes the rows one by
> one.

I did some testing, but the problem is that Linux keeps the memoryprint
of the program eventhough you have freed the allocated memory. I have
found that if I remove some elements from my list say half there is no
change in the reported memoryprint, but if I free all the elements the
memoryprints goes back to what it was before it was allocated.

So it is a bit tricky to check it.

The test:

   Loaded a big datafile into my own list package

   * App size: 4.5Mb -> 16Mb
   
   Freed the whole of this list

   * App size: 16Mb -> 4.5Mb
   
   Loaded the same file again:

   * App size: 4.5Mb -> 16Mb

   Called the procedure for adding the data to the Clist

   * App size: 16Mb -> 29Mb

   Closed the Clist (calls Clear)

   * App size: 29Mb

   Freed the whole list again

   * App size: 29Mb

   Loaded List again:

   * App size: 29Mb

   Called Clist again:

   * App size: 29Mb

So far this shows that there is no leak.

   Closed Clist and Loaded New bigger List:
   
   * App size: 29Mb -> 31Mb 
   
   Called Clist
   
   * App size: 31Mb -> 41Mb

Exited the program and started it again.

   Loaded the bigger list:

   * App size: 4.5Mb -> 22Mb

   Called Clist:

   * App size: 22Mb -> 41Mb

So my conclusion is that there isn't a memory leak.

-- 
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
                 «For me, Ada95 puts back the joy in programming.»




More information about the gtkada mailing list