[Haskell-cafe] garbage collection for a data structure
haskell at elisehuard.be
Tue Jan 20 10:03:16 UTC 2015
> Yes, sort of. You can use that to tell if a certain *constructor* has been
> collected, but that's not always so helpful. For instance, if you make a
> weak pointer to a list, and find that it's been collected, that just means
> the first (:) constructor has been collected. It may well be that the rest
> of the list spine and all its elements are still live. I ran into this
> problem trying to find out if an Array had been collected. It turned out
> that the Array constructor that holds the array bounds had been, but the
> actual Array# holding the elements was still around!
Ah, thanks, that clears it up somewhat
> I'm not sure what the deal is there exactly, but my *guess* is that GHC may
> never actually bother allocating x or z at all. Finalizers are not
> guaranteed to ever run; they're a sort of "please, if you have the time"
> kind of thing.
Ah, you mean the literals may fall under this?
Or are they optimized away because never actually used?
Thanks, I learned something. I changed the program to perform an
operation and print out the result with the values, but the finalizer
still didn't run - I might shelve this one for later examination.
More information about the Haskell-Cafe