On 09/10/10 19:11, Axel Simon wrote: > > 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.
I haven't followed the thread in detail, but perhaps the difference you're seeing is because with -threaded, GHC does a full GC after a certain amount of idle time, by default 0.3s. See the +RTS -I flag in the documentation: http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/runtime-control.html Cheers, Simon ------------------------------------------------------------------------------ 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