[Haskell-cafe] Re: Timeouts that don't cause data growth.
Bas van Dijk
v.dijk.bas at gmail.com
Tue Mar 23 19:04:14 EDT 2010
On Tue, Mar 23, 2010 at 10:20 PM, Simon Marlow <marlowsd at gmail.com> wrote:
> The leak is caused by the Data.Unique library, and coincidentally it was
> fixed recently. 6.12.2 will have the fix.
Oh yes of course, I've reported that bug myself but didn't realize it
was the problem here :-)
David, to clarify the problem: newUnqiue is currently implemented as:
newUnique :: IO Unique
newUnique = do
val <- takeMVar uniqSource
let next = val+1
putMVar uniqSource next
return (Unique next)
You can see that the 'next' value is lazily written to the uniqSource
MVar. When you repeatedly call newUnique (like in your example) a big
thunk is build up: 1+1+1+...+1 which causes the space-leak. In the
recent fix, 'next' is strictly evaluated before it is written to the
MVar which prevents a big thunk to build up.
regards,
Bas
More information about the Haskell-Cafe
mailing list