On Oct 9, 2010, at 18:23, John Obbele wrote:

> Hi again !
>
> On Sat, Oct 09, 2010 at 05:10:36PM +0200, Axel Simon wrote:
>> Yes, that's the notion. mainGUI must be "__safe" because it will
>> call back into Haskell land. Once a callback from the mainGUI thread
>> is triggered and we're in Haskell land again, GC and all other
>> Haskell threads will run.
>>
>> But I'm not that this explains why we see the space leak without -
>> threaded. If your Haskell program does not run then it can't create
>> garbage. If it runs, the GC will run.
>>
>> There is some C code that might behave differently, depending on
>> weather we're in -threaded mode or not. I'll check.
>
> @Axel, sorry to bother you with another tricky question but I've
> played with pixbufs in a callback glib function (code attached),
> and forcing the GC with System.Mem.performGC seems to be the only
> way to avoid a memory issue, when compiled without any
> '-threaded' option.
>
> I'm really puzzled by this behaviour since it shows GHC runtime
> would be able to clean the heap, but will not do it unless you
> explicitly ask for.
>

Ah, ok. Maybe it's because ghc optimizes the callback in a way that it  
doesn't allocate anything in the heap or not enough to trigger a GC.  
Mind you, if you allocate a 4MB image and only a 16-byte thunk within  
Haskell to point to it, it will take a long time until the Haskell  
heap is full so that a GC is triggered. If you use -threaded then ghc  
might do something else and generate more garbage.

This is what just came to my mind. It might still have a deeper cause.

Cheers,
Axel

>
> Well, anyway, as Andy asked, I will try to fix floating
> references in the rest of the Gtk objects. I guess using
> [0][GObject official hierarchy], hierachy.list and a smart sed
> script can help me to speed things up.
>
> [0]: http://library.gnome.org/devel/gtk/stable/ch01.html
>
> regards,
> /John
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating  
> great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Gtk2hs-devel mailing list
> Gtk2hs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Gtk2hs-devel mailing list
Gtk2hs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel

Reply via email to