re: memory leak in glib? (fwd)




---------- Forwarded message ----------
Date: Thu, 3 Dec 1998 00:50:38 -0800
From: dannys@mail.com
To: Havoc Pennington <rhpennin@midway.uchicago.edu>
Subject: re: memory leak in glib?

Hi, I mailed this to the gtk-devel-list, but I don't recall seeing it
sent back to me.  And I still haven't seen a single response.  If you
didn't see it either, would you mind forwarding it for me?

Thanks,
Danny Sung

----> snip <----

>about glib/gtk that some memory is never freed, and the rationale is given
>that this particular memory should only be freed when the program exits at
>which point there's no reason to bother. So if this was another example of
>that, don't worry about it. If not, you should probably resend your mail. 

Okay, thanks.  I don't think it's one of those.  It happens in the
linked list, hash, etc. routines.  It's probably lower level than
that, but I didn't look too deep.  Here's my previous email:

 
 Sorry if this is the wrong place for this, but I couldn't find a glib
 specific mailing list on the gtk.org web site.
 
 Anyways, can someone tell me if I'm just doing something idiotic, or if
 there's some weird interplay between libraries, or if there's really a
 memory leak in glib?
 
 Appended is a little test program I wrote.  But I get memory leaks
 running the stock testglib as well.
 
 Thanks,
 Danny Sung
 
 
 
 Here's my code:
 
  #include <stdio.h>
  #include <string.h>
  #include <stdlib.h>
  #include <glib.h>
  
  int main(int argc, char *argv[])
  {
     GPtrArray *ga;
     char *ptr;
  
     printf("garray test\n");
     ga = g_ptr_array_new();
  
     ptr = malloc(987);
  
     g_ptr_array_free(ga, 1);
  
     printf("blow chunks\n");
     g_blow_chunks();
     return(0);
  }
 
 Compiling with the following line:
    cc -o test_garray test_garray.o /home/dannys/z/glib-1.1.5/.libs/libglib.a  -lccmalloc -ldl
 
 
 As you can see, I'm using ccmalloc (v0.2.3 -
 http://iseran.ira.uka.de/~armin/ccmalloc/).  And when I execute the
 code, I get the following results:
 
  .--------------------------------------------------------------------------.
  |================ ccmalloc-0.2.3 (C) 1997-1998 Armin Biere ================|
  +--------------------------------------------------------------------------+
  | executable       = ./test_garray                                         |
  | startup file     = ~/.ccmalloc                                           |
  | log file         = stderr                                                |
  | start time       = Tue Nov 24 00:50:43 1998                              |
  | operating system = Linux 2.0.35 i586 on gaia.nature.earth                |
  +--------------------------------------------------------------------------+
  | only-count        = 0            keep-deallocated-data = 0               |
  | check-interval    = 0            check-free-space      = 0               |
  | check-start       = 0            file-info             = 1               |
  | chain-length      = 0            additional-line       = 1               |
  | check-underwrites = 0            print-addresses       = 0               |
  | check-overwrites  = 0            print-on-one-line     = 0               |
  | sort-by-wasted    = 1            sort-by-size          = 1               |
  | # only-log-chain  = 0            continue              = 0               |
  | # dont-log-chain  = 0            statistics            = 0               |
  | debug             = 0            library-chains        = 0               |
  | load-dynlibs      = 0            align-8-byte          = 0               |
  `--------------------------------------------------------------------------'
  
  .---------------.
  |ccmalloc report|
  =======================================================
  | total # of|   allocated | deallocated |     garbage |
  +-----------+-------------+-------------+-------------+
  |      bytes|        4231 |        1024 |        3207 |
  +-----------+-------------+-------------+-------------+
  |allocations|           9 |           1 |           8 |
  +-----------------------------------------------------+
  | number of checks: 1                                 |
  | number of counts: 10                                |
  | retrieving function names for addresses ... done.   |
  | reading file info from gdb ... done.                |
  | sorting by number of not reclaimed bytes ... done.  |
  | number of call chains: 8                            |
  | number of ignored call chains: 0                    |
  | number of reported call chains: 8                   |
  | number of internal call chains: 8                   |
  | number of library call chains: 0                    |
  =======================================================
  |
  * 31.9% = 1024 Bytes of garbage allocated in 1 allocation
  |       |
  |       |       0x08049388 in <main>
  |       |                  at test_garray.c:12
  |       |
  |       |       0x08049762 in <g_ptr_array_new>
  |       |                  at garray.c:240
  |       |
  |       |       0x08049f86 in <g_mem_chunk_alloc>
  |       |                  at gmem.c:624
  |       |
  |       |       0x0804b37b in <g_tree_insert>
  |       |                  at gtree.c:125
  |       |
  |       |       0x0804b6b3 in <g_tree_node_insert>
  |       |                  at gtree.c:295
  |       |
  |       |       0x0804b627 in <g_tree_node_new>
  |       |                  at gtree.c:259
  |       |
  |       |       0x08049f4c in <g_mem_chunk_alloc>
  |       |                  at gmem.c:608
  |       |
  |       |       0x08049bd6 in <g_malloc>
  |       |                  at gmem.c:156
  |       |
  |       `-----> 0x0804da90 in <malloc>
  |                          at wrapper.c:325
  |        
  * 31.9% = 1024 Bytes of garbage allocated in 1 allocation
  |       |
  |       |       0x080493bd in <main>
  |       |                  at test_garray.c:20
  |       |
  |       |       0x0804a31a in <g_blow_chunks>
  |       |                  at gmem.c:855
  |       |
  |       |       0x0804a180 in <g_mem_chunk_clean>
  |       |                  at gmem.c:755
  |       |
  |       |       0x0804b3c8 in <g_tree_remove>
  |       |                  at gtree.c:139
  |       |
  |       |       0x0804b81d in <g_tree_node_remove>
  |       |                  at gtree.c:382
  |       |
  |       |       0x0804d3c0 in <g_slist_prepend>
  |       |                  at gslist.c:137
  |       |
  |       |       0x0804d31c in <g_slist_alloc>
  |       |                  at gslist.c:72
  |       |
  |       |       0x08049f4c in <g_mem_chunk_alloc>
  |       |                  at gmem.c:608
  |       |
  |       |       0x08049bd6 in <g_malloc>
  |       |                  at gmem.c:156
  |       |
  |       `-----> 0x0804da90 in <malloc>
  |                          at wrapper.c:325
  |        
  * 30.8% = 987 Bytes of garbage allocated in 1 allocation
  |       |
  |       |       0x08049397 in <main>
  |       |                  at test_garray.c:14
  |       |
  |       `-----> 0x0804da90 in <malloc>
  |                          at wrapper.c:325
  |        
  |  1.6% = 52 Bytes of garbage allocated in 1 allocation
  |       |
  |       |       0x08049388 in <main>
  |       |                  at test_garray.c:12
  |       |
  |       |       0x0804974f in <g_ptr_array_new>
  |       |                  at garray.c:234
  |       |
  |       |       0x08049ccf in <g_mem_chunk_new>
  |       |                  at gmem.c:423
  |       |
  |       |       0x08049bd6 in <g_malloc>
  |       |                  at gmem.c:156
  |       |
  |       `-----> 0x0804da90 in <malloc>
  |                          at wrapper.c:325
  |        
  |  1.6% = 52 Bytes of garbage allocated in 1 allocation
  |       |
  |       |       0x08049388 in <main>
  |       |                  at test_garray.c:12
  |       |
  |       |       0x08049762 in <g_ptr_array_new>
  |       |                  at garray.c:240
  |       |
  |       |       0x08049f86 in <g_mem_chunk_alloc>
  |       |                  at gmem.c:624
  |       |
  |       |       0x0804b37b in <g_tree_insert>
  |       |                  at gtree.c:125
  |       |
  |       |       0x0804b6b3 in <g_tree_node_insert>
  |       |                  at gtree.c:295
  |       |
  |       |       0x0804b614 in <g_tree_node_new>
  |       |                  at gtree.c:257
  |       |
  |       |       0x08049ccf in <g_mem_chunk_new>
  |       |                  at gmem.c:423
  |       |
  |       |       0x08049bd6 in <g_malloc>
  |       |                  at gmem.c:156
  |       |
  |       `-----> 0x0804da90 in <malloc>
  |                          at wrapper.c:325
  |        
  |  1.6% = 52 Bytes of garbage allocated in 1 allocation
  |       |
  |       |       0x080493bd in <main>
  |       |                  at test_garray.c:20
  |       |
  |       |       0x0804a31a in <g_blow_chunks>
  |       |                  at gmem.c:855
  |       |
  |       |       0x0804a180 in <g_mem_chunk_clean>
  |       |                  at gmem.c:755
  |       |
  |       |       0x0804b3c8 in <g_tree_remove>
  |       |                  at gtree.c:139
  |       |
  |       |       0x0804b81d in <g_tree_node_remove>
  |       |                  at gtree.c:382
  |       |
  |       |       0x0804d3c0 in <g_slist_prepend>
  |       |                  at gslist.c:137
  |       |
  |       |       0x0804d2fa in <g_slist_alloc>
  |       |                  at gslist.c:65
  |       |
  |       |       0x0804d2d3 in <g_slist_set_allocator>
  |       |                  at gslist.c:50
  |       |
  |       |       0x08049ccf in <g_mem_chunk_new>
  |       |                  at gmem.c:423
  |       |
  |       |       0x08049bd6 in <g_malloc>
  |       |                  at gmem.c:156
  |       |
  |       `-----> 0x0804da90 in <malloc>
  |                          at wrapper.c:325
  |        
  |  0.2% = 8 Bytes of garbage allocated in 1 allocation
  |       |
  |       |       0x08049388 in <main>
  |       |                  at test_garray.c:12
  |       |
  |       |       0x0804974f in <g_ptr_array_new>
  |       |                  at garray.c:234
  |       |
  |       |       0x08049d1f in <g_mem_chunk_new>
  |       |                  at gmem.c:436
  |       |
  |       |       0x0804b2a6 in <g_tree_new>
  |       |                  at gtree.c:93
  |       |
  |       |       0x08049bd6 in <g_malloc>
  |       |                  at gmem.c:156
  |       |
  |       `-----> 0x0804da90 in <malloc>
  |                          at wrapper.c:325
  |        
  |  0.2% = 8 Bytes of garbage allocated in 1 allocation
  |       |
  |       |       0x080493bd in <main>
  |       |                  at test_garray.c:20
  |       |
  |       |       0x0804a31a in <g_blow_chunks>
  |       |                  at gmem.c:855
  |       |
  |       |       0x0804a180 in <g_mem_chunk_clean>
  |       |                  at gmem.c:755
  |       |
  |       |       0x0804b3c8 in <g_tree_remove>
  |       |                  at gtree.c:139
  |       |
  |       |       0x0804b81d in <g_tree_node_remove>
  |       |                  at gtree.c:382
  |       |
  |       |       0x0804d3c0 in <g_slist_prepend>
  |       |                  at gslist.c:137
  |       |
  |       |       0x0804d2fa in <g_slist_alloc>
  |       |                  at gslist.c:65
  |       |
  |       |       0x0804d2a7 in <g_slist_set_allocator>
  |       |                  at gslist.c:45
  |       |
  |       |       0x0804cc1e in <g_list_allocator_new>
  |       |                  at glist.c:40
  |       |
  |       |       0x08049bd6 in <g_malloc>
  |       |                  at gmem.c:156
  |       |
  |       `-----> 0x0804da90 in <malloc>
  |                          at wrapper.c:325
  |        
  `------------------------------------------------------
  garray test
  blow chunks
  
 



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