How to check for memory leak.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
zbo
Reply | Threaded
Open this post in threaded view
|

How to check for memory leak.

zbo
I was using the code from

http://www.haskell.org/hawiki/HaskellNewbie_2fTcpIpAndNetworking

It seems to be losing a few Kbytes every call (i use 'top' on linux to check the
RES field value).

I dont know whether this is a memory leak or just the GC not collecting yet.
I was just wondering What is the general method to check this.

BTW, I have tried using -prof and -P, but not really able to see anything
suspicious.

Cheers,
ed

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: How to check for memory leak.

Malcolm Wallace
zbo <[hidden email]> writes:

> I dont know whether this is a memory leak or just the GC not collecting yet.
> I was just wondering What is the general method to check this.
>
> BTW, I have tried using -prof and -P, but not really able to see anything
> suspicious.

You want to use heap profiling, not time profiling.

  * Compile with -prof -auto-all.
  * Run with +RTS -hc -RTS.
       (or perhaps various other options all beginning -h)
  * Convert the resulting .hp file to postcript using hp2ps.
  * View the postscript diagram.
  * If there is a ramp that grows and never drops, there is a
    persistent space leak.  On the other hand, large spikes can
    also be a space problem.  The ideal shape is mostly-flat.

See the ghc users guide sections 5.4 and 5.6.  For papers about how to
interpret profile graphs, try (for instance)

  C.Runciman and D.Wakeling. Heap profiling of lazy functional programs.
  Journal of Functional Programming, 3(2):217-245, 1993.

  C.Runciman and N.Rojemo. New dimensions in heap profiling. Journal of
  Functional Programming, 6(4):587-620, 1996.

Regards,
    Malcolm
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe