[Haskell-cafe] garbage collection for a data structure
ky3 at atamo.com
Tue Jan 20 11:54:30 UTC 2015
I remember that your earlier email on the beginner list asked about
"diffing from moment to moment." Perhaps you can sketch what you're trying
Because once you get into the internals of GC the learning ramp gets very,
very steep. There are traps known and unknown for both the wary and unwary,
as a cursory overview of GHC trac will inform.
There's probably a way of getting things to work without relying on
On Mon, Jan 19, 2015 at 7:10 PM, Elise Huard <haskell at elisehuard.be> wrote:
> I was wondering if there was a way to check whether a particular data
> structure gets garbage collected in a program. A friendly person
> pointed me to System.Mem.Weak on the Haskell-Beginner list - however
> I've been unable to verify how it works, so I'm bumping it to this
> See the following toy program: I was trying to see whether the output
> would contain "garbage collected".
> I wondered if performGC is a nudge rather than an immediate "garbage
> collect now" instruction, and performGC is not actually performed? Or I've
> misunderstood finalizers in this context and they would not actually
> be executed when z gets garbage collected?
> import System.Mem.Weak
> import System.Mem (performGC)
> import Control.Concurrent (threadDelay)
> main :: IO ()
> main = do let x = 5
> y = "done"
> z = 3
> a <- mkWeak z x (Just (putStrLn "garbage collected"))
> threadDelay 20000000
> print y
> Thank you,
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe