memory leak with gdk_fontset_load/gdk_font_unref while using XFree-4 libs
- From: Guillaume Cottenceau <gc mandrakesoft com>
- To: gtk-devel-list gnome org
- Subject: memory leak with gdk_fontset_load/gdk_font_unref while using XFree-4 libs
- Date: 06 Oct 2000 13:06:12 +0200
Hi,
I am developper for MandrakeSoft, who produces the Linux distribution
called Linux-Mandrake.
I had trouble with xmms, actually a memory leak that made it eat more than
150 Megabytes of memory after a long use.
After much investigation, I finally figured out where the problem comes
from, and the little program at the bottom can reproduce it:
gdk_font_unref seems to not release correctly the memory if it was created
with gdk_fontset_load; additionnally, it seems that the problem only
occurs when the prog is linked against X libraries from XFree-4 (does NOT
appear when the prog is linked against XFree-3).
I did not verify on current CVS if this bug seems to be fixed; however I
checked the archive of this ML and it seems that it was not reported
before.
-=-=-=-=-=-=-=-
#include <stdio.h>
#include <gtk/gtk.h>
void print_mem()
{
FILE *stream_;
char point[1000];
char filen[100];
char *f_,*g_;
int t;
t = getpid();
sprintf(filen, "/proc/%d/status", t);
if((stream_ = fopen(filen, "r")) == NULL)
return;
fread(point, 1, 1000, stream_);
fclose(stream_);
point[999] = '\0';
f_ = (char *) strstr(point,"VmSize");
if (!f_) return;
g_ = (char *) strchr(f_, '\n');
if (!g_) return;
g_[1] = '\0';
printf(f_);
}
int main(int argc, char **argv)
{
GdkFont *font = NULL;
int i;
gtk_init(&argc, &argv);
printf("Starting at:\t\t\t"); print_mem();
for (i=0; i<200; i++)
{
font = gdk_font_load("-adobe-helvetica-bold-r-*-*-10-*");
gdk_font_unref(font);
}
printf("After some font_load:\t\t"); print_mem();
for (i=0; i<200; i++)
{
font = gdk_fontset_load("-adobe-helvetica-bold-r-*-*-10-*,*-r-*");
gdk_font_unref(font);
}
printf("After some fontset_load:\t"); print_mem();
}
-=-=-=-=-=-=-=-
Output of this program on a Linux-Mandrake 7.2-beta machine is:
Starting at: VmSize: 4252 kB
After some font_load: VmSize: 4252 kB
After some fontset_load: VmSize: 4844 kB
Versions of progs we use:
gtk+-1.2.8
glib-1.2.8
XFree86-4.0.1
glibc-2.1.3
linux-2.2.17
--
Guillaume Cottenceau -- Distribution Developer for MandrakeSoft
http://www.mandrakesoft.com/~gc/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]