Calculate size of GHC objects in Bytes. Note that an object may not be evaluated yet and only the size of the initial closure is returned.
Calculate the recursive size of GHC objects in Bytes. Note that the actual size in memory is calculated, so shared values are only counted once.
recursiveSize $! 2
to force evaluation to WHNF before calculating the size.
recursiveSize $!! "foobar"
($!! from Control.DeepSeq) to force full evaluation before calulating the size.
A garbage collection is performed before the size is calculated, because the garbage collector would make heap walks difficult.