Re: Memory Usage
- From: Andre Messerschmidt <a_messerschmidt yahoo com>
- To: Ivan Baldo <ibaldo adinet com uy>
- Cc: GTK Mailinglist <gtk-list gnome org>
- Subject: Re: Memory Usage
- Date: Tue, 24 Oct 2006 00:10:39 -0700 (PDT)
Sure. Would be great if it is just a simple misunderstanding on how to use GTK.
----- snip -------------------------------------------------------
#include <stdio.h>
#include <signal.h>
#include <gtk/gtk.h>
GtkWidget *window, *window1;
GtkWidget *fixed;
GtkWidget *frame1;
GtkWidget *frame2;
GtkWidget *frame3;
struct sigaction xact;
void GtkCreateWindow()
{
window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request (window, 100, 100);
gtk_window_set_resizable(GTK_WINDOW(window1), 1);
gtk_window_set_decorated(GTK_WINDOW(window1), 1);
gtk_window_set_gravity(GTK_WINDOW(window1), GDK_GRAVITY_CENTER);
gtk_window_move(GTK_WINDOW(window1),200,10);
gtk_widget_show (window1);
}
void outer_signal_handler(int iSigno, siginfo_t *pxsigInfo,
void *context)
{
static int i=0;
printf("---- Signal handler Start -----------------------------------------------------\n");
if ((i % 2) == 0)
{
printf("i=%d creating\n",i);
GtkCreateWindow();
}
else
{
printf("i=%d destroying\n",i);
gtk_widget_destroy(GTK_WIDGET(window1));
}
i++;
printf("---- Signal handler End -------------------------------------------------------\n");
}
int main( int argc,char *argv[] )
{
gtk_init (&argc, &argv);
xact.sa_sigaction = outer_signal_handler;
sigemptyset (&xact.sa_mask);
xact.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
if (sigaction(SIGUSR2, &xact, NULL) < 0)
{
fprintf(stderr,
"sigaction failed\n");
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_gravity(GTK_WINDOW(window), GDK_GRAVITY_CENTER);
gtk_window_move(GTK_WINDOW(window), 33,3);
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
gtk_widget_set_size_request (window, 320, 190);
fixed = gtk_fixed_new ();
gtk_container_add (GTK_CONTAINER (window), fixed);
gtk_widget_show (fixed);
frame1 = gtk_frame_new (NULL);
gtk_fixed_put (GTK_FIXED (fixed), frame1, 0, 0);
gtk_widget_set_size_request (frame1, 160,40);
gtk_frame_set_shadow_type (GTK_FRAME (frame1), GTK_SHADOW_OUT);
gtk_widget_show (frame1);
frame2 = gtk_frame_new (NULL);
gtk_fixed_put (GTK_FIXED (fixed), frame2, 0, 40);
gtk_widget_set_size_request (frame2, 160,150);
gtk_frame_set_shadow_type (GTK_FRAME
(frame2), GTK_SHADOW_OUT);
gtk_widget_show (frame2);
frame3 = gtk_frame_new (NULL);
gtk_fixed_put (GTK_FIXED (fixed), frame3, 0, 190);
gtk_widget_set_size_request (frame3, 320,40);
gtk_frame_set_shadow_type (GTK_FRAME (frame3), GTK_SHADOW_OUT);
gtk_widget_show (frame3);
gtk_widget_show (window);
gtk_main();
return 0;
}
----- snap -------------------------------------------------------
This program should create a window and then after receiving a USR2 signal display or destroy another window. Here I can see that if I do this long enough, my memory keeps decreasing until only 1MB is left (from initially 128MB)
Hope it helps.
best regards
Andre
Ivan Baldo <ibaldo adinet com uy> wrote:
Can you post the source code of your test application?
GTK doesn't seem to leak memory on i386, it shouldn't on MIPS...
Thank you.
Yahoo! Messenger with Voice.
Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]