[Haskell-cafe] possible memory leak in uvector 0.1.0.3

Daniel Fischer daniel.is.fischer at web.de
Tue Mar 3 09:47:36 EST 2009


Am Dienstag, 3. März 2009 15:35 schrieb Manlio Perillo:
> Claus Reinke ha scritto:
> >>> At first guess it sounds like you're holding onto too much, if not the
> >>> whole stream perhaps bits within each chunk.
> >>
> >> It is possible.
> >>
> >> I split the string in lines, then map some functions on each line to
> >> parse the data, and finally calling toU, for converting to an UArr.
> >
> > Just to make sure (code fragments or, better, reduced examples
> > would make it easier to see what the discussion is about): are you
> > forcing the UArr to be constructed before putting it into the Map?
>
> parse handle =
>    contents <- S.hGetContents handle
>    let v =  map singleton' $ ratings contents
>    let m = foldl1' (unionWith appendU) v
>    v `seq` return $! m

The (v `seq` ) is completely useless.
Maybe 
	(size m) `seq` return m
would help?

>
>    where
>      -- Build a Map with a single movie rating
>      singleton' :: (Word32, Word8) -> MovieRatings
>      singleton' (id, rate) =
>        singleton (fromIntegral $ id) (singletonU $ pairS (id, rate))



More information about the Haskell-Cafe mailing list