
GHC's great space profiling tools don't appear to be much help when your leaked memory is stored in references (IORefs, StablePtrs, etc). I had a real-life case where the allocation profile showed me where the leaked data came from, and I could guess that it was being held by some reference, but I couldn't tell which one. Retainer set profiling showed a big suspicious entry for "SYSTEM", but I couldn't find any way to pinpoint the problem. (It ended up being a missing freeStablePtr in hsgnutls, found by code inspection.) Here's a contrived example that just allocates a bunch of IORefs: import Control.Monad import Data.IORef main = repeatM (newIORef [1,2,3]) repeatM io = liftM2 (:) io (repeatM io) Retainer set profiling shows everything in "SYSTEM". None of the other profiling methods say anything interesting either. What I'd like to get, I think, is (1) your memory is being held in IORefs (2) allocated by this cost center and (3) being retained by this cost center. I guess I'm looking for something like a memory profiler for a traditional language. But I haven't really thought it all out (and I don't even understand everything the existing profiles tell me). Are there some tricks I've missed for this sort of debugging? And perchance would this be an interesting GHC hackathon subject? Andrew
participants (1)
-
Andrew Pimlott