Re: Dtrace and glib
- From: "Veerapuram Varadhan" <vvaradhan novell com>
- To: <desktop-devel-list gnome org>
- Subject: Re: Dtrace and glib
- Date: Wed, 11 Jan 2006 04:19:07 -0700
On Wed, 2006-01-11 at 08:11 +0000, "Veerapuram Varadhan" wrote:
> Hi,
>
> I have gnusolaris (nexenta os) installed and was running dtrace on
> evolution to find memory leaks. When I was running valgrind on
> evolution, couple of months back, I had a custom built gnome
environment
> with a "disabled mem pool" glib. In gnusolaris, I don't have a glib
> with a "disabled mem pool", because of which, dtrace reports lots of
> (false) memory leaks.
>
> Is there any option to specify glib to disable mem pools? (without
> compiling it?)
>
Found a way to work-around (or is it the only way?) this by the
following script...
#!/usr/sbin/dtrace -s
pid$target:libglib-2.0.so.0:g_malloc:entry
{
self->trace = 1;
self->size = arg0;
}
pid$target:libglib-2.0.so.0:g_malloc:return
/self->trace == 1/
{
printf("Ptr=0x%p Size=%d", arg1, self->size);
ustack();
self->trace = 0;
self->size = 0;
}
pid$target:libglib-2.0.so.0:g_realloc:entry
{
self->trace = 1;
self->size = arg1;
self->oldptr = arg0;
}
pid$target:libglib-2.0.so.0:g_realloc:return
/self->trace == 1/
{
printf("Ptr=0x%p Oldptr=0x%p Size=%d", arg1, self->oldptr,
self->size);
ustack();
self->trace = 0;
self->size = 0;
}
pid$target:libglib-2.0.so.0:g_malloc0:entry
/self->trace == 1/
{
self->trace = 1;
self->size = arg1;
}
pid$target:libglib-2.0.so.0:g_malloc0:return
/self->trace == 1/
{
printf("Ptr=0x%p Size=%d", arg1, self->size);
ustack();
self->trace = 0;
self->size = 0;
}
pid$target:libglib-2.0.so.0:g_free:entry
{
printf("Ptr=0x%p ", arg0);
}
and tested the following sample program:
#include <stdio.h>
#include <glib.h>
int
main ()
{
gchar* str = NULL;
int i;
for (i = 0; i < 10; i++) {
str = g_strdup ("0123456789");
printf ("%s\n", str);
g_free (str);
}
return 0;
}
and it printed.... (after processing the output dump of my dtrace
script)
Total memory leak (in bytes): 0
V. Varadhan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]