From 6ca9b15f77e58931953edb7c872b803cb261fce9 Mon Sep 17 00:00:00 2001 From: Jason Eisenberg Date: Sat, 5 Mar 2016 20:00:38 +0100 Subject: GHCi: Fix load/reload space leaks (#4029) This patch addresses GHCi load/reload space leaks which could be fixed without adversely affecting performance. Test Plan: make test "TEST=T4029" Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: mpickering, thomie Differential Revision: https://phabricator.haskell.org/D1950 GHC Trac Issues: #4029 --- ghc/GHCi/UI.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ghc') diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 4b39159c83..cc180f27ff 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -1463,7 +1463,8 @@ checkModule m = do -- '-fdefer-type-errors' again if it has not been set before. deferredLoad :: Bool -> InputT GHCi SuccessFlag -> InputT GHCi () deferredLoad defer load = do - originalFlags <- getDynFlags + -- Force originalFlags to avoid leaking the associated HscEnv + !originalFlags <- getDynFlags when defer $ Monad.void $ GHC.setProgramDynFlags $ setGeneralFlag' Opt_DeferTypeErrors originalFlags Monad.void $ load @@ -3483,7 +3484,8 @@ showException se = ghciHandle :: (HasDynFlags m, ExceptionMonad m) => (SomeException -> m a) -> m a -> m a ghciHandle h m = gmask $ \restore -> do - dflags <- getDynFlags + -- Force dflags to avoid leaking the associated HscEnv + !dflags <- getDynFlags gcatch (restore (GHC.prettyPrintGhcErrors dflags m)) $ \e -> restore (h e) ghciTry :: GHCi a -> GHCi (Either SomeException a) -- cgit v1.2.1