
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
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.
: 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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Eugene Kirpichov Web IR developer, market.yandex.ru _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe