GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Jul 22, 2014 1:26 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: gtk2.0 memory allocation for command gtk_image /
PostPosted: Wed Oct 09, 2013 10:24 am 
Offline
Familiar Face

Joined: Fri Oct 26, 2012 10:49 am
Posts: 35
On a board with embedded linux, using the command "top", I see that my application needs more and more memory (column VSZ)
I have a suspicion that the 2 next functions are guilty of it, they use the commands "gtk_image_new_from_file" and "gtk_image_new_from_pixbuf"
Is there something I had to do to free the memory after having called these functions?
The variables GtkWidget *image; and GdkPixbuf *pixbuf are only local variables iin the function

Thanks a lot in advance
MBoerner



Code:
/**************************
* this function set a text and an icon on a button
* @param button
* @param text
* @param name of icon
* @param screen
*/
void ts_design_taskbar_buttons(GtkWidget *screen, GtkWidget *button, char *text, const gchar *symbolname)

{
   GtkWidget *image;
   char folder[56] = BUTTON_SYMB_FOLDER;
   char iconnameWithPath[100];
   // symbols
   if (symbolname != NULL ) {
      strcpy(iconnameWithPath, "");
      strcpy(iconnameWithPath, folder);
      strcat(iconnameWithPath, symbolname);
      image = gtk_image_new_from_file(iconnameWithPath);
      gtk_button_set_image(GTK_BUTTON(button), image);
   }
   gtk_button_set_label(GTK_BUTTON(button), text);
   gtk_button_set_image_position(GTK_BUTTON(button),GTK_POS_TOP );  // sets the position of the icon over the text
   //
   if (screen!=NULL)
      gtk_widget_show_all(GTK_WIDGET(screen) );
}


or
Code:
{
....
GdkPixbuf       *pixbuf   =   NULL;
GError          *error = NULL;
pixbuf = gdk_pixbuf_new_from_file(p_spinDirIconnameWithPath, &error);
if(!pixbuf)
{
    fprintf(stderr, "%s\n", error->message);
   if (error != NULL) g_error_free (error);
}
else
   rm_local.widgets.spinDirIcon = gtk_image_new_from_pixbuf(pixbuf);
....


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group