How to orderly empty a tree view without memory leakage?



What am I supposed to do in order to cleanly free the contents of a tree
view without memory leakage in GTK+ 2.2.? I have a tree view which is to
be refilled with completely different data when the user of my program
selects different data sources.

My approach was to
1. gtk_tree_view_remove_column (tv, column) for every
   gtk_tree_view_get_column (tv, 0) there is,
3. gtk_tree_view_set_model (tv, NULL) to free(?) the existing model.

However, there is still a noticable increase of memory consumption by the
program, each time when I refill the tree view. I then added step 2:

2. gtk_tree_view_get_model (tv) and g_object_unref () it!

Though I rather expected a segfault by this, it actually works and I even
believe the growth of memory consumption has decreased a bit (though not
ceased completely).

- Is my observation of decreased growth of memory consumption on manually 
  g_object_unref'ing the model reproducible for some of you or am I wrong?
- Am I really supposed to manually g_object_unref () the model?
- Should I manually g_object_unref () more objects, for instance the
  columns, before removing them or is it a bug in GTK+ 2.2 that models
  have to be unref'd manually to prevent memory leaks?
- What about cell renderers? Are they (supposed to be) unref'd / freed
  implicitly when all columns are removed or should I (try to) unref them?



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