[Top][All Lists]

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

[Xlog-discussion] Need some advice on memory debugging

From: Joop Stakenborg
Subject: [Xlog-discussion] Need some advice on memory debugging
Date: Thu, 7 Mar 2002 13:44:51 +0100

Biggest issue at the moment for xlog is keeping track of all the
calls to g_strdup, g_new, g_malloc, g_strdup_printf, g_free,

I am at a point where the code becomes unmaintainable. Although
the program behaves like it should, I can only achieve correct
behaviour by removing some of the calls to g_free, which in fact
are needed to free mem. 

If I leave the free's in, I get segfaults (mostly at program exit,
where I free most of the memory).

I have looked into gccchecker, electric-fence, dmalloc and ccmalloc,
which are all packages designed to keep track of used and free'd
memory. All of these packages are somehow unusable with xlog,
because I don't have debug versions installed of all the libraries
xlog is linked with. There are some workarounds for this, but they
all involve quite a bit of hacking....

Next, I have been looking at some other gtk applications, as I
thought more people might experience the kind of problems I am
having. I have looked at xchat and irssi, both quite complicated
irc clients. They both use functions which replace existing
memory functions by their own functions (when compiled with
some flag like MEM_DEBUG), e.g.:

XCHAT: #define malloc(n) xchat_malloc(n, __FILE__, __LINE__)
IRSSI: #define g_malloc(a) ig_malloc(a, __FILE__, __LINE__)

These functions produce mem statistics which are printed to stdout
and they check whether mem is correctly allocated or free'd.

Anyone have experience with memory debugging? What is the way
to go?

Joop PA4TU

reply via email to

[Prev in Thread] Current Thread [Next in Thread]