[Haskell-cafe] Memory

Jeff Douglas inbuninbu at gmail.com
Tue Feb 17 00:53:37 EST 2009


Thanks Guys,

Not only did I not run optimizations, I misread the profile. It looks
like it was an imaginary problem from the beginning. I guess I should
go through all the profiling documentation more carefully.

Jeff

On Tue, Feb 17, 2009 at 2:46 PM, Bernie Pope <bjpop at csse.unimelb.edu.au> wrote:
>
> On 17/02/2009, at 3:56 PM, Jeff Douglas wrote:
>
>> Hello All,
>>
>> The kind people at #haskell suggested I come to haskell-cafe for
>> questions about haskell performance issues.
>> I'm new to haskell, and I'm having a hard time understanding how to
>> deal with memory leaks.
>>
>> I've been playing with some network server examples and I noticed with
>> each new connection, the memory footprint increases by about 7k
>> However, the leaks don't seem to have anything to do with the
>> networking code. Actually I get a huge leak just from using using
>> 'forever'.
>>
>>> import Control.Monad
>>> import System.IO
>>>
>>> main = forever $ putStrLn "hi"
>>
>> When I run it for a few seconds with profiling...
>>
>>> total time  =        0.36 secs   (18 ticks @ 20 ms)
>>> total alloc =  54,423,396 bytes  (excludes profiling overheads)
>>
>> Can this be right?
>
>
> I don't think there should be a space leak in the code you posted.
>
> On my mac, OS X 10.5.6, GHC version 6.8.3, it appears to run in constant
> space with or without optimisation.
>
> GHCi seems to gobble a little bit of memory (but that could be incidental).
>
> My terminal application does gobble memory for a while (and then frees it),
> but that is presumably because it is hammering the buffer (and it nearly
> sets my lap on fire when running).
>
> Perhaps you could post more details about how it is compiled, and what
> versions of things are being used.
>
> How are you detecting the leak (via top?).
>
> Cheers,
> Bernie.
>
>
>


More information about the Haskell-Cafe mailing list