[Haskell-cafe] number of references to a variable

Andrew Coppin andrewcoppin at btinternet.com
Sat Nov 1 09:38:40 EDT 2008


Alberto G. Corona wrote:
> Is there a way to know the number of memory references for a variable?. 
> The runtime must know it but i do not know if this available for the 
> program trough any low level trick

More precisely, the GC computes it each time it runs. (And only computes 
it precisely during a "major" pass, not the more frequent "minor" passes.)

You can attach a finaliser to an object, and that'll allow you to know 
when the reference count reaches zero. But beyond that, I don't know.



More information about the Haskell-Cafe mailing list