Re: Memory Leak Tool with GLib Applications



Hi Owen and others,

Thanks! I have tried using the memprof 5.1 (preloaded on RH 9.0) with some glib applications.

Most glib applications run fine, except the multi-threaded ones. I have found that when I use memprof on a multi-threaded glib applications, the application simply hangs at the g_thread_create(). My system is RH 9.0 and is using pthread.

If I use memprof on the below application, it stops right after "Creating thread1" is displayed.

Is it a known issue? Any workaround?

Thanks a lot.

Regards,
Tony Cheung
#include <glib.h>

gpointer test_thread(gpointer data) {
}

int main() {

  GThread *thread1;

  if (!g_thread_supported ())
    g_thread_init (NULL);

  printf("Creating thread1\n");
  thread1 = g_thread_create(test_thread, NULL, TRUE, NULL);
  printf("thread 1 created\n");

}


Owen Taylor wrote:
On Tue, 2003-10-21 at 04:07, Tony Cheung wrote:
  
Hi,

I am using glib as a foundation library for some C application developments.

I have been using mpatrol, as a memory leakage detection tool. However, 
when I use mpatrol with glib applications, it reports some false memory 
leaks. Does anyone have any experience of using mpatrol with glib 
applications?

It seems that glib allocates some blocks of memory and keep reusing 
them. When the application quits, it relies on the OS itself to free the 
memory.
    

[...]

  
Is any way to use mpatrol with glib applications? Or is there any other 
memory leakage tool which works with glib nicely?
    

http://people.redhat.com/otaylor/memprof/memtools.html

Of the tools listed there, Memprof, Valgrind, Debauch, and the Boehm
GC are all smart enough to detect when memory is *actually* leaked.

I'd recommend either Memprof (simple, to the point, pretty easy
to use GUI, but badly maintained) or Valgrind (all sorts of power,
well maintained, but more complex) if you are running on Linux.
On other operating systems, the Boehm GC would be your best bet.

  
Does glib provide some destruction functions for cleaning up those 
unused memory blocks when application quits?
    

No. (http://bugzilla.gnome.org/show_bug.cgi?id=64096 is a request
for such, but it is unlikely to happen any time soon)

Regards,
					Owen
  



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