[Haskell-cafe] Re: Looking for the fastest Haskell primes

Daniel Peebles pumpkingod at gmail.com
Thu Apr 16 07:11:01 EDT 2009


I vaguely remember someone (maybe Duncan Coutts?) saying that this was
a commonly held misconception, and that GHC did indeed GC CAFs when
optimization is enabled. If I am remembering incorrectly, does anyone
have a reference to a ticket outlining this non-GC'ed CAF behavior?

Thanks,
Dan

On Thu, Apr 16, 2009 at 4:57 AM, Eugene Kirpichov <ekirpichov at gmail.com> wrote:
> The parameterless version is a top-level definition and won't get
> garbage-collected, IIRC.
> So, if you evaluate primes!!10000000, you'll end up with a
> 10000000-element list hanging in memory forever.
> If you evaluate (primes' ()) !! 10000000, you won't.
>
> 2009/4/16 Niemeijer, R.A. <r.a.niemeijer at tue.nl>:
>> Heinrich Apfelmus wrote:
>>> +1 except that exporting the potentially infinite list of primes is
>>> problematic in that it may become a memory leak.
>>>
>>> I'd suggest to export two versions
>>>
>>>   primes  :: [Integer]
>>>   primes' :: () -> [Integer]
>>>
>>> for casual (i.e. throwaway program to solve a Project Euler problem) and
>>> for memory aware use respectively.
>>
>> I'm afraid I don't quite follow. Would you mind explaining what the first parameter is for and how it would solve the memory leak?
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>
>
>
> --
> Eugene Kirpichov
> Web IR developer, market.yandex.ru
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list