[Haskell-cafe] Question about memory usage

Sebastian Fischer sebf at informatik.uni-kiel.de
Wed Aug 18 07:16:47 EDT 2010


Hi John,

> You could try: [...]
>
> It allocates less and has a smaller maximum residency: (ghc  
> 6.12.2,windows 7 64)
>
>     292,381,520 bytes allocated in the heap
>      13,020,308 bytes maximum residency (8 sample(s))
>               99 MB total memory in use (9 MB lost due to  
> fragmentation)
>
>  MUT   time    5.85s  (  5.88s elapsed)
>
> instead of:
>
>    451,864,588 bytes allocated in the heap
>       17,362,424 bytes maximum residency (8 sample(s))
>               99 MB total memory in use (9 MB lost due to  
> fragmentation)
>
>  MUT   time    9.11s  (  9.14s elapsed)

Interesting. It uses the same amount of memory but is faster probably  
because it allocates less.

But I prefer programs for people to read over programs for computers  
to execute and I have a hard time to verify that your algorithm  
computes Fibonacci numbers. I find it much easier to see from my  
implementation. Is your implementation the same algorithm? If yes, the  
transformations you made by hand should ideally be made by the compiler!

Cheers,
Sebastian

-- 
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)





More information about the Haskell-Cafe mailing list