LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 01-27-2006, 10:12 AM   #1
isindelar
LQ Newbie
 
Registered: Jan 2006
Posts: 2

Rep: Reputation: 0
Question Memory leak with Gtk+-2.0


My C++ GUI application on Linux Fedora uses Gtk+-2.0 and Glade-2.0 and underlying libraries. One window is frequently created and destroyed, but the memory usage always goes up, never down. When the window is created and displayed, a large chunk of memory is allocated. When it is destroyed, not only does this memory seem not to be recovered, but a further small chunk of memory is allocated. Using refdbg, I can see that the numerous objects allocated for the window are destroyed when the window is destroyed, so why does the memory usage go up not down?

I think Gtk makes extensive use of realloc - could this be causing memory to become fragmented and result in more/bigger blocks of memory being allocated?

My Gtk reference mentions that Gtk does garbage collection "when it gets around to it" - is there a way to force garbage collection?

Thanks for any advice.
 
Old 01-27-2006, 02:47 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Not really answering your question but, I don't tend to delete windows rather I toggle the hide / show attribute. This is the "typical approach" although for an application with lots of windows or dynamically created windows this is not appropriate.

I don't know Gtk+ so I would ask are you sure that you are actually deleting the window? If so I guess that it's a garbage problem which you could test by throwing your create and destroy window functions in a loop (several million times should trigger it) and track the memory.

graeme.
 
Old 02-08-2006, 08:48 AM   #3
isindelar
LQ Newbie
 
Registered: Jan 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Smile thanks for the help

Thanks for the help, your suggestion worked great.
 
  


Reply



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
Memory leak?! nyk Programming 10 01-24-2005 07:08 PM
what is memory leak blackzone Programming 6 11-05-2004 10:32 AM
possible memory leak?? matt80 Linux - General 2 07-01-2004 11:07 PM
Memory Leak don_dimo Linux - General 7 03-06-2004 06:51 PM
Memory Leak when using memory debugging C program on SuSE SLES8 babalina Linux - Distributions 0 10-06-2003 09:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:54 AM.

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