Hi John, Andy,

On Oct 9, 2010, at 15:15, John Obbele wrote:

> Hi Andy,
>
> On Sat, Oct 09, 2010 at 05:06:57PM +0800, Andy Stewart wrote:
>> just need figure out why it can't work when disable "-thread" flag.
>
> Hum ... got some sleep and I've re-read the GHC documentation on
> [0]. They say "It is a common misconception that you need to use
> forkOS instead of forkIO to avoid blocking all the Haskell
> threads when making a foreign call; this isn't the case. To allow
> foreign calls to be made without blocking all the Haskell threads
> (with GHC), it is only necessary to use the -threaded option when
> linking your program, and to make sure the foreign import is not
> marked unsafe."
>
> [0]:
> http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Concurrent.html#v%3AforkOS
>
> Does that mean calling `mainGUI` in a program build without
> '-threaded' blocks all the GHC runtime threads, including the
> garbage collector ?
>

Yes, that's the notion. mainGUI must be "unsafe" 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.

Thanks for investigating,
Axel

> /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