Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-18-2010, 08:52 PM   #1
Registered: Apr 2010
Posts: 130
Blog Entries: 5

Rep: Reputation: 2
Lightbulb Can gtk free widget ?

Hello everyone!

I am confused that after I call gtk_button_new() many times, how can I free these buttons. Let's see the following codes:

Gtkwidget *button;
button = gtk_button_new();  //the first call
button = gtk_button_new();  //the second call
button = gtk_button_new();  // the third call
The gtk_button_new() was called three times, and I think memory is eaten by every call, how can I release the memory used by the first and second calls.
Do other gtk Widgets work similar to button ?
Old 08-19-2010, 10:46 AM   #2
Registered: Mar 2007
Distribution: GNU/Linux debian unstable main
Posts: 93

Rep: Reputation: 17
RE: Can gtk free widget ? Reply to Thread

You may use gtk_widget_destroy which should destroy all child widgets, too. Pack it in a container or save a pointer to the widgets eg. in a GList, that you can free it's memory.

the code above will only destroy the last button which it has a reference to.

Last edited by joel2001k; 08-19-2010 at 10:50 AM.
1 members found this post helpful.


free, gtk, memory, widget

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Showing a widget above a widget in GTK aarontwc Programming 4 11-26-2008 12:40 PM
How to use the GTK Iconview widget LinuxNoob75 Programming 1 12-29-2007 07:40 PM
GTK widget which to use? cranium2004 Programming 1 02-20-2006 02:29 PM
Which GTK Widget to use? jpbarto Programming 0 11-20-2003 08:34 PM
what is a gtk-widget ? gladeiator Programming 3 10-30-2003 06:34 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:37 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration