You're right, I don't free the elements in the list before calling
g_slist_free.

Thank you.


2010/10/7 Tadej Borovšak <[email protected]>

> Hi.
>
> 2010/10/7 Márcio Ricardo Pivello <[email protected]>:
> > Hi all.
> > I use a library called GTS for computational geometry tasks, and it is
> > heavily based on GLib data structures. Specifically, in _many_ occasions
> it
> > returns a GSList* containing vertices, edges and so on, which you use and
> > then delete with g_slist_free( ). In my work, during a transient
> simulation
> > this kind of operation occurs at least tens of millions of times. Since
> > g_slist_free( ) does not actually deallocates the memory used by the
> list,
> > my program always ends consuming all available memory during the
> simulation
> > (8 GB, when it should use just 10% of that).
>
> I don't think g_slist_free() is problematic here. My guess would be
> that you're not freeing your data that is pointed to by list elements.
> g_slist_free() will only free memory that is used by GSList structs,
> data that is pointed to by data member of GSList structure needs to be
> freed separately.
>
> For example, take gtk_icon_view_get_selected_items() func. Usual usage is:
>
> GSList *items = gtk_icon_view_get_selected_items (icon_view);
>
> /* Do something here */
>
> g_slist_foreach (items, (GFunc)gtk_tree_path_free, NULL);
> g_slist_free (items);
>
> The important line is g_slist_foreach() line, where actual data that
> is pointed to by nodes is freed.
>
> Tadej
>
> --
> Tadej Borovšak
> tadeboro.blogspot.com
> [email protected]
> [email protected]
>



-- 
Márcio Ricardo Pivello
Universidade Federal de Uberlândia
Faculdade de Engenharia Mecânica
Laboratório de Mecânica dos Fluidos
+55 (34) 3239 4040 ramal 618
_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to