[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
HELP:glist hogging memory [BUG?]
- From: Javier Terradas <terry ati es>
- To: gtk-app-devel-list redhat com
- Subject: HELP:glist hogging memory [BUG?]
- Date: Sun, 31 Oct 1999 13:13:59 +0100 (CET)
Hi,
I'm stuck with a glist problem. Whenever I put something in a list data I
can't free its memory, I receive no error but the memory gets lots. I've
read the docs and I'm completely stuck with this one.
Here I put one of the tests I've tried. I fill a dynamically generated
array. With no options it just gets freed without problem (output 1),
but if I put the data in a list it never gets freed (output 2). Here is
the test program and the output it generates.
Please help.
-- Javi --
---------------------------- exemple.c---------------------------------
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <glib.h>
#define DEB_LINES 200000
void create_list(gpointer **array, gint *i)
{
gint j;
for (j=0;j<DEB_LINES;j++)
array[j] = (gpointer) malloc(50);
}
int
main (int argc, char *argv[])
{
gint i, lin;
gpointer **array;
gint j = 0;
GList *l = NULL;
GList *laux;
system("free");
array = g_malloc(DEB_LINES * sizeof(gchar *));
create_list(array, &lin);
printf ("\n--- Got memory -------\n");
system("free");
if (argc == 2 && argv[1][0] == 'l') {
for ( i = 0; i < DEB_LINES; i++)
l = g_list_prepend(l, array[i]);
printf ("\n--- All in list -------\n");
system("free");
}
for ( i = 0; i < DEB_LINES; i++) {
free( array[i]);
}
printf ("\n--- Freed memory? -------\n");
system("free");
return 0;
}
----------------------------------------------------------------------------
If I just fill up the array the memory gets immediately freed:
=========================== output 1 ===================================
[terry@madriguera src]$ ./prova4
total used free shared buffers cached
Mem: 63324 48236 15088 10944 13384 26776
-/+ buffers/cache: 8076 55248
Swap: 64224 768 63456
--- Got memory -------
total used free shared buffers cached
Mem: 63324 59964 3360 11004 13384 26776
-/+ buffers/cache: 19804 43520
Swap: 64224 768 63456
--- Freed memory? -------
total used free shared buffers cached
Mem: 63324 49024 14300 11008 13384 26776
-/+ buffers/cache: 8864 54460
Swap: 64224 768 63456
============================================================================
but if I give te option to fill a glist with it it gets completely stuck.
======================= output 2 ======================================
terry@madriguera src]$ ./prova4 l
total used free shared buffers cached
Mem: 63324 50168 13156 10944 14512 27568
-/+ buffers/cache: 8088 55236
Swap: 64224 768 63456
--- Got memory -------
total used free shared buffers cached
Mem: 63324 61896 1428 11004 14512 27568
-/+ buffers/cache: 19816 43508
Swap: 64224 768 63456
--- All in list -------
total used free shared buffers cached
Mem: 63324 62224 1100 11024 13384 26648
-/+ buffers/cache: 22192 41132
Swap: 64224 768 63456
--- Freed memory? -------
total used free shared buffers cached
Mem: 63324 62224 1100 11024 13384 26648
-/+ buffers/cache: 22192 41132
Swap: 64224 768 63456
terry@madriguera src]$
==========================================================================
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]