[Gtk-sharp-list] Disposing problem
Sun, 09 Nov 2003 11:32:41 -0500
The problem is that you're not a GUI app. :-)
PerformQueuedUnrefs is called from the Idle handler for the GUI. The
Idle handler is run whenever the GUI is not busy.
(Recall that GUIs are event-driven, so if the user isn't doing anything,
and the app isn't doing anything, then the app is idle, so you can do
background work during idle processing.)
Your sample app doesn't have a GUI, so there's never an "idle time", so
the idle handler is never run, so PerfrmQueuedUnrefs is never called.
Some possible solutions:
- Insert the code:
// do nothing
This should explicitly run the idle handler. This should be run
after the .Dispose() call.
- Make Object.Dispose virtual, then make Pixbuf.Dispose free memory
This probably isn't a good idea, as GTK+ requires that all objects
be disposed from the same thread, which is what PerformQueuedUnrefs
does (since the idle handler is only run on the GUI thread, so only
one thread will ever do the unrefs).
Pixbuf might not have this requirement, though. I have no idea.
The first option is the safest and simplest option, if it works. Please
try it and let us know.
On Sat, 2003-11-08 at 13:55, Bruno Fernandez-Ruiz wrote:
> On Sat, 2003-11-08 at 20:54, Gonçal Carrero Puig wrote:
> > Anyone knows why idle is never calling PerformedQueuedUnrefs?
> I have seen similar problems in due to the GC thread never entering, and
> the heap expanding until memory exhaustion. Try to create many dummy
> objects that implement IDisposable, and see if they get reclaimed. When
> running the attached sample, I freeze the system and run out of memory.
> No collection ever happens.
> Is GC disabled by default in mono?