On Fri, 14 Jun 2013 23:03:55 +0530
dE <de.tec...@gmail.com> wrote:
> On 06/14/13 22:09, Chris Vine wrote:
> > On Fri, 14 Jun 2013 21:41:05 +0530
> > dE<de.tec...@gmail.com>  wrote:
> >> On 06/14/13 17:02, Matthias Clasen wrote:
> >>> On Fri, Jun 14, 2013 at 3:27 AM, dE<de.tec...@gmail.com>  wrote:
> >>>> I was monitoring the memory usage before and after execution of
> >>>> g_object_unref and gtk_list_store_clear, and it didnt change the
> >>>> memory usage by a bit.
> >>>>
> >>>> Is this normal (am I doing it right?)?
> >>> What are you monitoring, and how ?
> >>>
> >>> It is i normal that freeing memory does not change the resource
> >>> consumption of the process. The freed memory will be available for
> >>> reuse by malloc, but malloc does not immediately return the memory
> >>> to the OS.
> >> No, filled more than 7GB, swap was at ~350 MB, and then I loaded a
> >> small table which would otherwise take less than 10 MB memory, but
> >> the memory usage increased.
> > Can you post the smallest compilable program which demonstrates your
> > problem (run with G_SLICE=always-malloc set), and with particulars
> > of how you are measuring memory usage?  That should identify if you
> > are doing something wrong with how you are handling the memory in
> > your program.
> >
> > Chris
> >
> 
> You can have the whole source code:
> 
> http://pastebin.com/4a5DiMsQ
> 
> I'd been distributing it around to fix issues.

This isn't going to help I am afraid.

On some general observations on your earlier questions however:

A GtkBuilder object is a plain GObject.  It will be freed by calling
g_object_unref() on it.  That will also cause it to release its
references to the objects it has created.  Whether that will destroy
those created objects depends on whether there are any other
references to them which have been acquired, such as by their having
been put in a container.  If so, then you need to release those other
references as well in order to destroy the created objects and free
their memory.  Top level windows need to have gtk_widget_destroy()
called on them.  If you want to remove a widget from a container or top
level window but keep the container or top level window alive, you can
cause the container to release its reference with
gtk_container_remove().  If you want all containers holding a reference
to a particular GtkWidget to release their references so leading to the
widget's destruction, call gtk_widget_destroy() on the widget.

For plain GObjects, namely those which are not created with a floating
reference (and so are not derived from GInitiallyUnowned/GtkWidget),
to free them you need to have called g_object_unref() on them explicitly
as well as destroy (or remove them from) their container (if any):
except that GtkBuilder will already have done that for you if it
supplies a plain GObject already embedded in a container it has
supplied. For objects derived from GInitiallyUnowned/GtkWidget,
destroying (or removing them from) their container by one of the means
mentioned above is enough.

You may be aware of all that.  If so I am afraid you need to break your
code down to see whether you have discovered a referencing bug (not
likely but possible - I have reported referencing bugs before now), or
you have neglected to release something somewhere.

Chris
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to