Opened 4 years ago

Closed 4 years ago

#4208 closed bug (fixed)

ghci/Linker.lhs space leaks

Reported by: TristanAllwood Owned by: igloo
Priority: normal Milestone: 7.0.1
Component: GHC API Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Lots of repeated calls to getHValue in ghci/Linker.lhs will cause a thunk to grow (THUNK_2_0 according to -hT). Calling showLinkerState
after each getHValue (in an attempt to force it) shows PersistentLinkerState? grows in size quite rapidly.

Possibly related: #4029

Attachments (1)

X.ps (15.2 KB) - added by TristanAllwood 4 years ago.
Heap profile

Download all attachments as: .zip

Change History (5)

comment:1 Changed 4 years ago by TristanAllwood

(I plan to knock up a minimal example to demonstrate this v.soon)

comment:2 Changed 4 years ago by TristanAllwood

Small example to replicate, (uses ghc-paths from hackage)

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MagicHash #-}
module Main where

import GHC.Paths
import GHC
import Control.Monad
import PrelNames
import Linker
import GHC.Prim
import MonadUtils

main :: IO ()
main = runGhc (Just libdir) $ do
  dflags' <- getSessionDynFlags 
  primPackages <- setSessionDynFlags dflags'
  dflags <- getSessionDynFlags
  defaultCleanupHandler dflags $ do
    liftIO $ initDynLinker dflags
    liftIO $ linkPackages dflags primPackages
    replicateM_ 1000000 $ do
      !printVal <- getSession >>= (liftIO . flip getHValue printName)
      return ()

run with

ghc --make -package ghc X.hs
./X +RTS -hT -RTS

hp2ps graph output attached

Changed 4 years ago by TristanAllwood

Heap profile

comment:3 Changed 4 years ago by igloo

  • Owner set to igloo

comment:4 Changed 4 years ago by igloo

  • Milestone set to 6.14.1
  • Resolution set to fixed
  • Status changed from new to closed

Thanks for the report; fixed:

Tue Jul 27 21:19:11 BST 2010  Ian Lynagh <igloo@earth.li>        
  * Make PersistentLinkerState fields strict; fixes #4208
  We modify fields a lot, so we retain the old value if they aren't forced.
Note: See TracTickets for help on using tickets.