Re: [gtk-list] Gtk Text Widget memory leak?

On Sun, Jun 14, 1998 at 08:31:47PM -0400, wrote:
> 	Hello, I'm having a slight problem with GTK's Text widget in
> Linux. It seems when I add text to the widget, and then destroy it, the
> memory is not freed. I'm not sure of this, but what I did to test was load
> large files (kernel, etc) into the text widget, destroyed the widget,
> create a new text widget, load a large file, etc... and in the process
> doing a 'ps ux' to check memory usage. I've noticed that the %MEM field of
> the ps output rises considerably as each file is loaded and does not go
> down once the text widget is destroyed.
> 	Is this normal? What should the proper way that a Text widget
> should be destroyed? Right now I am using gtk_widget_destroy on the dialog
> that contains the text widget (and have also tried destroying the actual
> text widget). Any help appreciated.
> 	Viraj.

i believe what you're seeing is not specific to the text widget.
it's up the C library to return memory back to the system.
try this program:

#include <stdio.h>
#include <time.h>
#include <sys/resource.h>

void main(void)
	struct rusage rustats;
	char *buf;

	buf = (char *)malloc(2048*2048);	/* 4MB */

	getrusage(RUSAGE_SELF, &rustats);
	printf("maxrss: %ld\n", rustats.ru_maxrss);

	getchar(); /* hit enter to continue, or do a 'ps' here */

	getrusage(RUSAGE_SELF, &rustats);
	printf("maxrss: %ld\n", rustats.ru_maxrss);

i'm pretty sure that the memory use will not go down after the
free.  it will be released when it's necessary (since it's no
longer actually used), but you won't see it happen immediately.

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