GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Apr 20, 2014 8:16 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: memory leak
PostPosted: Sun Jun 10, 2012 1:45 pm 
Offline
Familiar Face

Joined: Sun Feb 12, 2012 2:23 pm
Posts: 7
Hello,
I have two functions, first one show some info
Code:
    G_MODULE_EXPORT void message(const gchar *message)
    {
            GtkWidget   *dialog;     
            dialog = gtk_message_dialog_new(NULL,
                                            GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                            GTK_MESSAGE_INFO,
                                            GTK_BUTTONS_OK,
                                            message);
           
            gtk_window_set_title(GTK_WINDOW(dialog), "Info!");
            gtk_dialog_run(GTK_DIALOG(dialog));     
            gtk_widget_destroy(dialog);         
    }


second function uses the first one to display appropriate message
Code:
    G_MODULE_EXPORT void on_anuluj(GtkWidget *widget, gpointer user_data)
    {
       gint      ret, argc, err;
       gchar    *reset, **argv, *out_err = NULL;
       GError   *error = NULL;
       GIOChannel   *err_ch;
       gsize      err_msg_s;
       
       reset = g_strdup("shutdown.exe -a");
       g_shell_parse_argv(reset, &argc, &argv, NULL);
       g_free(reset);
       ret = g_spawn_async_with_pipes(NULL, argv,
                               NULL, G_SPAWN_SEARCH_PATH,
                               NULL, NULL,
                               0, NULL,
                               NULL, &err,
                               &error);
       if(!ret)
       {
          message(error->message);
          g_error_free(error);
       }
       g_strfreev(argv);
       err_ch = g_io_channel_win32_new_fd(err);
       g_io_channel_set_encoding(err_ch, "CP1250", NULL);
       g_io_channel_read_line(err_ch, &out_err, &err_msg_s, NULL, NULL);
       if(out_err != NULL)
       {
          /* Nie mozna przerwac procesu zamykania systemu,
          poniewaz taki proces nie jest w toku.(1116) */
          message(out_err);
          g_free(out_err);
       }
       else
       {
          message("Anulowano zamykanie systemu...");
       }   
       g_io_channel_unref(err_ch);   
    }



after several calls to second function memory size grows. Where I'm not releasing memory?


Top
 Profile  
 
 Post subject: Re: memory leak
PostPosted: Mon Jun 11, 2012 6:47 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 709
Location: UK
Hi,

I do not see any memory related problems here as all resources seam to be cleaned up properly.

How are you measuring the memory leaks?

Remember that Glib and GTK caches memory use, so that may appear as a growth in memory depending on how you measure it. You could also have memory fragmentation which can make memory usage appear to grow.

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group