Re: GTK free function doesn't appear to have any affect.

2013-06-17 Thread dE

On 06/16/13 21:35, Chris Vine wrote:

On Sun, 16 Jun 2013 12:28:52 +0530
dE de.tec...@gmail.com wrote:

Apart from that, in the free_ptr? Does memory get freed for anyone
else?

#include stdio.h
#include gtk/gtk.h
#define COLS 200
void free_ptr ( GtkListStore * );

int main (  ) {
  gtk_init( NULL, NULL );
  int i, j;
  char *temp;
  GtkTreeIter current;
  GType *str_type = g_malloc (sizeof (GType) * COLS);
  for (i = 0; i  COLS; i++)
  str_type [i] = G_TYPE_STRING;
  GtkListStore *store = gtk_list_store_newv (COLS, str_type);
  g_free (str_type);
  for (i = 0; i  30 ; i++) {
  gtk_list_store_append ( store, current );
  for ( j = 0 ; j  COLS ; j++ ) {
  gtk_list_store_set ( store , current , j , Hello world
Hello world Hello world!, -1 );
  }
  }
  printf ( freeing after 10 seconds\n );
  sleep (10);
  free_ptr ( store );
  printf (Now freed\n);
  sleep (10);
  return 0;
}

void free_ptr ( GtkListStore *store ) {
  gtk_list_store_clear (store);
  g_object_unref( G_OBJECT (store) );
}

You should compile your code with warnings enabled.  Then you would
find out other things about your code (namely that 'temp' is not used).
Apart from that, technically the code is OK and it does destroy the
list store correctly.

Turning to the main point, the thing about your code is that it is
inadequate for detecting memory leakage, because it does not take
account of caching.  To come up with a meaningful test, you need to
rerun the memory-using code more than once in the program.  If you do
so, you will find that on each run other than the first, memory usage
does not increase.  From this I deduce (I hope) that list stores cache
the memory allocated to individual records for reuse. Presumably that
is thought to be an optimization for most uses.  In the pathological
case of a list store with 30 x 300 cells holding allocated strings
that clearly is not the case, but a list store with so many cells would
be unusably slow anyway when used in conjunction with a tree view.

There are various additional things you can do to check memory usage:
see https://developer.gnome.org/glib/2.36/glib-running.html .

For those kinds of pathological cases, you probably need to write your
own tree model which does things the way you want them.

Chris


I've realized, out of the allocated memory, after freeing it, although 
it's usage doesn't decrease, but if I start other programs which consume 
memory, it's memory usage decreases.

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


Re: GTK free function doesn't appear to have any affect.

2013-06-16 Thread dE

On 06/16/13 00:40, Allin Cottrell wrote:

On Sat, 15 Jun 2013, dE wrote:


On 06/15/13 14:24, dE wrote:
Yes, I realized that over time, but there appears to be something 
wrong with g_object_unref or in general all GTK free functions on my 
system.


In this piece of code --

#include stdio.h
#include gtk/gtk.h
#include stdlib.h
#include string.h
#define COLS 300
void main (  ) {
   gtk_init( NULL, NULL );


int i, j;
   char *temp;
   GtkTreeIter current;
   GType *str_type = g_malloc (sizeof (GType) * COLS);
for (i = 0; i = COLS; i++)
str_type [i] = G_TYPE_STRING;
   GtkListStore *store = gtk_list_store_newv (COLS, str_type);
   g_free (str_type);
   for (i = 0; i  30 ; i++) {
  gtk_list_store_append ( store, current );
   for ( j = 0 ; j  COLS ; j++ ) {
gtk_list_store_set ( store , current , j , Hello world 
Hello world Hello world!, -1 );

  }
   }
   printf ( freeing after 10 seconds\n );
   sleep (10);
   free_ptr ( store );
   printf (Now freed\n);
   sleep (10);
}

free_ptr ( GtkListStore *store ) {
   gtk_list_store_clear (store);
g_object_unref( G_OBJECT (store) );
}

Calling free_ptr ( store ); increases memory usage, even during the 
last 10 second free period. It'll take at most 7GB of memory.


Here there're no GtkWidgets involved. GtkListStore inherits directly 
from GObject.


Is this piece of code itself ok?


Certainly not. void main() is not valid C for a start (main must 
return int), then the first loop runs off the end of the str_type 
array...


Allin Cottrell



Apart from that, in the free_ptr? Does memory get freed for anyone else?

#include stdio.h
#include gtk/gtk.h
#define COLS 200
void free_ptr ( GtkListStore * );

int main (  ) {
gtk_init( NULL, NULL );
int i, j;
char *temp;
GtkTreeIter current;
GType *str_type = g_malloc (sizeof (GType) * COLS);
for (i = 0; i  COLS; i++)
str_type [i] = G_TYPE_STRING;
GtkListStore *store = gtk_list_store_newv (COLS, str_type);
g_free (str_type);
for (i = 0; i  30 ; i++) {
gtk_list_store_append ( store, current );
for ( j = 0 ; j  COLS ; j++ ) {
gtk_list_store_set ( store , current , j , Hello world 
Hello world Hello world!, -1 );

}
}
printf ( freeing after 10 seconds\n );
sleep (10);
free_ptr ( store );
printf (Now freed\n);
sleep (10);
return 0;
}

void free_ptr ( GtkListStore *store ) {
gtk_list_store_clear (store);
g_object_unref( G_OBJECT (store) );
}
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK free function doesn't appear to have any affect.

2013-06-16 Thread Chris Vine
On Sun, 16 Jun 2013 12:28:52 +0530
dE de.tec...@gmail.com wrote:
 Apart from that, in the free_ptr? Does memory get freed for anyone
 else?
 
 #include stdio.h
 #include gtk/gtk.h
 #define COLS 200
 void free_ptr ( GtkListStore * );
 
 int main (  ) {
  gtk_init( NULL, NULL );
  int i, j;
  char *temp;
  GtkTreeIter current;
  GType *str_type = g_malloc (sizeof (GType) * COLS);
  for (i = 0; i  COLS; i++)
  str_type [i] = G_TYPE_STRING;
  GtkListStore *store = gtk_list_store_newv (COLS, str_type);
  g_free (str_type);
  for (i = 0; i  30 ; i++) {
  gtk_list_store_append ( store, current );
  for ( j = 0 ; j  COLS ; j++ ) {
  gtk_list_store_set ( store , current , j , Hello world 
 Hello world Hello world!, -1 );
  }
  }
  printf ( freeing after 10 seconds\n );
  sleep (10);
  free_ptr ( store );
  printf (Now freed\n);
  sleep (10);
  return 0;
 }
 
 void free_ptr ( GtkListStore *store ) {
  gtk_list_store_clear (store);
  g_object_unref( G_OBJECT (store) );
 }

You should compile your code with warnings enabled.  Then you would
find out other things about your code (namely that 'temp' is not used).
Apart from that, technically the code is OK and it does destroy the
list store correctly.

Turning to the main point, the thing about your code is that it is
inadequate for detecting memory leakage, because it does not take
account of caching.  To come up with a meaningful test, you need to
rerun the memory-using code more than once in the program.  If you do
so, you will find that on each run other than the first, memory usage
does not increase.  From this I deduce (I hope) that list stores cache
the memory allocated to individual records for reuse. Presumably that
is thought to be an optimization for most uses.  In the pathological
case of a list store with 30 x 300 cells holding allocated strings
that clearly is not the case, but a list store with so many cells would
be unusably slow anyway when used in conjunction with a tree view.

There are various additional things you can do to check memory usage:
see https://developer.gnome.org/glib/2.36/glib-running.html .

For those kinds of pathological cases, you probably need to write your
own tree model which does things the way you want them.

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


Re: GTK free function doesn't appear to have any affect.

2013-06-16 Thread dE

On 06/16/13 21:35, Chris Vine wrote:

On Sun, 16 Jun 2013 12:28:52 +0530
dE de.tec...@gmail.com wrote:

Apart from that, in the free_ptr? Does memory get freed for anyone
else?

#include stdio.h
#include gtk/gtk.h
#define COLS 200
void free_ptr ( GtkListStore * );

int main (  ) {
  gtk_init( NULL, NULL );
  int i, j;
  char *temp;
  GtkTreeIter current;
  GType *str_type = g_malloc (sizeof (GType) * COLS);
  for (i = 0; i  COLS; i++)
  str_type [i] = G_TYPE_STRING;
  GtkListStore *store = gtk_list_store_newv (COLS, str_type);
  g_free (str_type);
  for (i = 0; i  30 ; i++) {
  gtk_list_store_append ( store, current );
  for ( j = 0 ; j  COLS ; j++ ) {
  gtk_list_store_set ( store , current , j , Hello world
Hello world Hello world!, -1 );
  }
  }
  printf ( freeing after 10 seconds\n );
  sleep (10);
  free_ptr ( store );
  printf (Now freed\n);
  sleep (10);
  return 0;
}

void free_ptr ( GtkListStore *store ) {
  gtk_list_store_clear (store);
  g_object_unref( G_OBJECT (store) );
}

You should compile your code with warnings enabled.  Then you would
find out other things about your code (namely that 'temp' is not used).
Apart from that, technically the code is OK and it does destroy the
list store correctly.

Turning to the main point, the thing about your code is that it is
inadequate for detecting memory leakage, because it does not take
account of caching.  To come up with a meaningful test, you need to
rerun the memory-using code more than once in the program.  If you do
so, you will find that on each run other than the first, memory usage
does not increase.  From this I deduce (I hope) that list stores cache
the memory allocated to individual records for reuse. Presumably that
is thought to be an optimization for most uses.  In the pathological
case of a list store with 30 x 300 cells holding allocated strings
that clearly is not the case, but a list store with so many cells would
be unusably slow anyway when used in conjunction with a tree view.

There are various additional things you can do to check memory usage:
see https://developer.gnome.org/glib/2.36/glib-running.html .

For those kinds of pathological cases, you probably need to write your
own tree model which does things the way you want them.

Chris


Yes, I've realized in the main program that once memory is consumed, it 
does not increase after the table is reloaded; however I filled the 
memory till the peak (=physical ram + some of swap), it still doesn't 
free for 10 seconds at least.


I'm running the link you provided. Thank you!
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK free function doesn't appear to have any affect.

2013-06-15 Thread dE

On 06/15/13 03:35, Chris Vine wrote:

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
dEde.tec...@gmail.com  wrote:

On 06/14/13 17:02, Matthias Clasen wrote:

On Fri, Jun 14, 2013 at 3:27 AM, dEde.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


Yes, I realized that over time, but there appears to be something wrong 
with g_object_unref or in general all GTK free functions on my system.


In this piece of code --

#include stdio.h
#include gtk/gtk.h
#include stdlib.h
#include string.h
#define COLS 300
void main (  ) {
   gtk_init( NULL, NULL );


int i, j;
   char *temp;
   GtkTreeIter current;
   GType *str_type = g_malloc (sizeof (GType) * COLS);
for (i = 0; i = COLS; i++)
str_type [i] = G_TYPE_STRING;
   GtkListStore *store = gtk_list_store_newv (COLS, str_type);
   g_free (str_type);
   for (i = 0; i  30 ; i++) {
  gtk_list_store_append ( store, current );
   for ( j = 0 ; j  COLS ; j++ ) {
gtk_list_store_set ( store , current , j , Hello world Hello 
world Hello world!, -1 );

  }
   }
   printf ( freeing after 10 seconds\n );
   sleep (10);
   free_ptr ( store );
   printf (Now freed\n);
   sleep (10);
}

free_ptr ( GtkListStore *store ) {
   gtk_list_store_clear (store);
g_object_unref( G_OBJECT (store) );
}

Calling free_ptr ( store ); increases memory usage, even during the last 
10 second free period. It'll take at most 7GB of memory.


Here there're no GtkWidgets involved. GtkListStore inherits directly 
from GObject.

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


Re: GTK free function doesn't appear to have any affect.

2013-06-15 Thread dE

On 06/15/13 14:24, dE wrote:

On 06/15/13 03:35, Chris Vine wrote:

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
dEde.tec...@gmail.com  wrote:

On 06/14/13 17:02, Matthias Clasen wrote:

On Fri, Jun 14, 2013 at 3:27 AM, dEde.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


Yes, I realized that over time, but there appears to be something 
wrong with g_object_unref or in general all GTK free functions on my 
system.


In this piece of code --

#include stdio.h
#include gtk/gtk.h
#include stdlib.h
#include string.h
#define COLS 300
void main (  ) {
   gtk_init( NULL, NULL );


int i, j;
   char *temp;
   GtkTreeIter current;
   GType *str_type = g_malloc (sizeof (GType) * COLS);
for (i = 0; i = COLS; i++)
str_type [i] = G_TYPE_STRING;
   GtkListStore *store = gtk_list_store_newv (COLS, str_type);
   g_free (str_type);
   for (i = 0; i  30 ; i++) {
  gtk_list_store_append ( store, current );
   for ( j = 0 ; j  COLS ; j++ ) {
gtk_list_store_set ( store , current , j , Hello world Hello 
world Hello world!, -1 );

  }
   }
   printf ( freeing after 10 seconds\n );
   sleep (10);
   free_ptr ( store );
   printf (Now freed\n);
   sleep (10);
}

free_ptr ( GtkListStore *store ) {
   gtk_list_store_clear (store);
g_object_unref( G_OBJECT (store) );
}

Calling free_ptr ( store ); increases memory usage, even during the 
last 10 second free period. It'll take at most 7GB of memory.


Here there're no GtkWidgets involved. GtkListStore inherits directly 
from GObject.


Is this piece of code itself ok?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK free function doesn't appear to have any affect.

2013-06-15 Thread Allin Cottrell

On Sat, 15 Jun 2013, dE wrote:


On 06/15/13 14:24, dE wrote:

On 06/15/13 03:35, Chris Vine wrote:

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
dEde.tec...@gmail.com  wrote:

On 06/14/13 17:02, Matthias Clasen wrote:

On Fri, Jun 14, 2013 at 3:27 AM, dEde.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


Yes, I realized that over time, but there appears to be something wrong 
with g_object_unref or in general all GTK free functions on my system.


In this piece of code --

#include stdio.h
#include gtk/gtk.h
#include stdlib.h
#include string.h
#define COLS 300
void main (  ) {
   gtk_init( NULL, NULL );


int i, j;
   char *temp;
   GtkTreeIter current;
   GType *str_type = g_malloc (sizeof (GType) * COLS);
for (i = 0; i = COLS; i++)
str_type [i] = G_TYPE_STRING;
   GtkListStore *store = gtk_list_store_newv (COLS, str_type);
   g_free (str_type);
   for (i = 0; i  30 ; i++) {
  gtk_list_store_append ( store, current );
   for ( j = 0 ; j  COLS ; j++ ) {
gtk_list_store_set ( store , current , j , Hello world Hello 
world Hello world!, -1 );

  }
   }
   printf ( freeing after 10 seconds\n );
   sleep (10);
   free_ptr ( store );
   printf (Now freed\n);
   sleep (10);
}

free_ptr ( GtkListStore *store ) {
   gtk_list_store_clear (store);
g_object_unref( G_OBJECT (store) );
}

Calling free_ptr ( store ); increases memory usage, even during the last 10 
second free period. It'll take at most 7GB of memory.


Here there're no GtkWidgets involved. GtkListStore inherits directly from 
GObject.


Is this piece of code itself ok?


Certainly not. void main() is not valid C for a start (main 
must return int), then the first loop runs off the end of the 
str_type array...


Allin Cottrell

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


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread Andrew Potter
On Fri, Jun 14, 2013 at 12: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?)?

 e.g. --
 gtk_list_store_clear (store);
 g_object_unref( G_OBJECT (store) );
 g_object_unref ( G_OBJECT ( col_renderer [j] ));

Do you have a treeview that is internally holding a reference to the list store?

I don't know about the GtkBuilder structures.

Also, g_new uses g_slice internally sometimes, and that will do things
like try to cache pages I think. Be sure to set the G_SLICE
environment variable to always-malloc when monitoring your memory
usage. See [1]

[1] https://developer.gnome.org/glib/2.36/glib-running.html
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread dE

On 06/14/13 13:24, Andrew Potter wrote:

On Fri, Jun 14, 2013 at 12: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?)?

e.g. --
gtk_list_store_clear (store);
g_object_unref( G_OBJECT (store) );
g_object_unref ( G_OBJECT ( col_renderer [j] ));

Do you have a treeview that is internally holding a reference to the list store?

I don't know about the GtkBuilder structures.

Also, g_new uses g_slice internally sometimes, and that will do things
like try to cache pages I think. Be sure to set the G_SLICE
environment variable to always-malloc when monitoring your memory
usage. See [1]

[1] https://developer.gnome.org/glib/2.36/glib-running.html


Before I unref and clear the ListStore I'm running 
gtk_tree_view_set_model (GtkTreeView *, NULL) on the TreeModel.


However there's a GtkTreeModelSort which holds the ListStore, this 
GtkTreeModelSort is then added to the TreeView.


I didnt find a way to unset the GtkTreeModelSort and the ListStore, but 
before I clear and unref the ListStore, I unref the GtkTreeModelSort.



gtk_tree_view_set_model ( ddisplay , NULL );
//unref to the TreeModelSort
g_object_unref ( G_OBJECT ( inter_sort ) );

gtk_list_store_clear (store);
g_object_unref( G_OBJECT (store) );

Setting export G_SLICE=always-malloc did nothing.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread Matthias Clasen
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.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread dE

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.


So I'll try allocating like 7GB of memory to fill up the ram, after 
finishing, it should free. I'll report back.

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


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread Tristan Van Berkom
On Sat, Jun 15, 2013 at 12:23 AM, 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.


 So I'll try allocating like 7GB of memory to fill up the ram, after
 finishing, it should free. I'll report back.

For more fine grained memory profiling you should use valgrind.

See some hints here for running your Glib program with valgrind:
https://live.gnome.org/Valgrind

Cheers,
-Tristan
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread dE

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.

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


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread dE

On 06/14/13 21:14, Tristan Van Berkom wrote:

On Sat, Jun 15, 2013 at 12:23 AM, 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.


So I'll try allocating like 7GB of memory to fill up the ram, after
finishing, it should free. I'll report back.

For more fine grained memory profiling you should use valgrind.

See some hints here for running your Glib program with valgrind:
 https://live.gnome.org/Valgrind

Cheers,
 -Tristan


http://forums.gentoo.org/viewtopic-t-961762.html

Do we have no other options? Like some kind of 'code sanitizer' which 
detects flaws in code related to memory?

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


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread Chris Vine
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

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


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread dE

On 06/14/13 22:09, Chris Vine wrote:

On Fri, 14 Jun 2013 21:41:05 +0530
dEde.tec...@gmail.com  wrote:

On 06/14/13 17:02, Matthias Clasen wrote:

On Fri, Jun 14, 2013 at 3:27 AM, dEde.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.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread Tristan Van Berkom
On Sat, Jun 15, 2013 at 2:33 AM, dE de.tec...@gmail.com wrote:
 On 06/14/13 22:09, Chris Vine wrote:

 On Fri, 14 Jun 2013 21:41:05 +0530
 dEde.tec...@gmail.com  wrote:

 On 06/14/13 17:02, Matthias Clasen wrote:

 On Fri, Jun 14, 2013 at 3:27 AM, dEde.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.

dE,

Surely you can conjure something small which you expect
not to leak memory, but does.

Obviously, there must be a leak in this program, but
sending us this huge file sort of implies that we should
do the debugging and find your memory leak for you.

If you send us something small, as Chris says:
the smallest compilable program which demonstrates
 your problem,

then we can surely easily spot the problem and guide you
on how to fix it, without spending our time doing your homework.

Cheers,
-Tristan
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread Chris Vine
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
  dEde.tec...@gmail.com  wrote:
  On 06/14/13 17:02, Matthias Clasen wrote:
  On Fri, Jun 14, 2013 at 3:27 AM, dEde.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


Re: GTK free function doesn't appear to have any affect.

2013-06-14 Thread dE

On 06/14/13 23:14, Tristan Van Berkom wrote:

On Sat, Jun 15, 2013 at 2:33 AM, dE de.tec...@gmail.com wrote:

On 06/14/13 22:09, Chris Vine wrote:

On Fri, 14 Jun 2013 21:41:05 +0530
dEde.tec...@gmail.com  wrote:

On 06/14/13 17:02, Matthias Clasen wrote:

On Fri, Jun 14, 2013 at 3:27 AM, dEde.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.

dE,

Surely you can conjure something small which you expect
not to leak memory, but does.

Obviously, there must be a leak in this program, but
sending us this huge file sort of implies that we should
do the debugging and find your memory leak for you.

If you send us something small, as Chris says:
 the smallest compilable program which demonstrates
  your problem,

then we can surely easily spot the problem and guide you
on how to fix it, without spending our time doing your homework.

Cheers,
 -Tristan


So I'll make a large GtkTreeStore, and try to free it.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list