GTK+ Forums

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

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Memory clean up without exit in gtk 3.0 ?
PostPosted: Thu Sep 06, 2012 12:43 pm 
Offline
Familiar Face

Joined: Thu Sep 06, 2012 8:45 am
Posts: 6
It it possible to clean up the memory used by gtk without exiting the program?.

In gtk 2.0 there where the gtk_exit that supposedly cleaned up the memory.
But how are you to clean up the memory in gtk 3.0 without using exit() and exiting the program?


Top
 Profile  
 
 Post subject: Re: Memory clean up without exit in gtk 3.0 ?
PostPosted: Thu Sep 06, 2012 2:22 pm 
Offline
Never Seen the Sunlight

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

Not sure what you really want to do. gtk_exit() has been deprecated for a very long time even in GTK+ v2 and should not be used. Even on GTK+ v2 all that gtk_exit() does is to call exit(). As for cleaning up GTK+ without exiting your application there is no portable way to do this.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Memory clean up without exit in gtk 3.0 ?
PostPosted: Thu Sep 06, 2012 3:11 pm 
Offline
Familiar Face

Joined: Thu Sep 06, 2012 8:45 am
Posts: 6
So the tool I have made, is running in 2 modes.

A 'watch' mode where it is watching for modification of a file, and a 'interactiv' mode where
it interact with the user.

Gtk is only used in the 'interactiv' mode. So memory allocation for gtk should be done in the start of the 'interactiv' mode and freeing should be done in the end of the 'interactiv' mode. And then it enter the 'watch' mode again.


Top
 Profile  
 
 Post subject: Re: Memory clean up without exit in gtk 3.0 ?
PostPosted: Thu Sep 06, 2012 4:12 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 709
Location: UK
The GIO library which is part of the GTK+ core set of libraries has file monitoring built-in.

What you would use is g_file_monitor_file() see http://developer.gnome.org/gio/stable/GFile.html#g-file-monitor-file and then set a signal call-back on the "changed" signal.

You therefore do not need to have "two modes" for your application.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Memory clean up without exit in gtk 3.0 ?
PostPosted: Thu Sep 27, 2012 4:53 pm 
Offline
Familiar Face

Joined: Thu Sep 06, 2012 8:45 am
Posts: 6
yes. I might use the GIO monitoring instead, but I will still have two "modes" or "states". One where I watch the file and one where I interact with the user. In the 'watch' state I would like to have a small memory footprint, so I don't fill up the memory with stuff that is not needed.

Does the GIO file monitoring also work on other platforms then Linux? Then that might be a reason to change.


Top
 Profile  
 
 Post subject: Re: Memory clean up without exit in gtk 3.0 ?
PostPosted: Thu Sep 27, 2012 5:49 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 709
Location: UK
GIO is a set of very portable library functions that deal with file IO, networking, file compression, and various other file related operations. It then integrates this with GObject and the GLib main loop so that signals can be connected to make very efficient code.

The library is very portable and works with Linux, other flavours of Unix, MacOS X and Windows (with some variations in function use due to the operating system).

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 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