[Haskell-cafe] Re: Timeouts that don't cause data growth.

David Leimbach leimy2k at gmail.com
Tue Mar 23 22:42:06 EDT 2010

On Tue, Mar 23, 2010 at 4:04 PM, Bas van Dijk <v.dijk.bas at gmail.com> wrote:

> 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

Thanks for this excellent description of what's going on.  This whole thread
has been a reminder of what makes the Haskell community truly excellent to
work with.  I appreciate everything you guys are doing!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100323/e13626e2/attachment.html

More information about the Haskell-Cafe mailing list