diff options
author | Jason Eisenberg <jasoneisenberg@gmail.com> | 2016-03-05 20:00:38 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-03-05 20:00:56 +0100 |
commit | 6ca9b15f77e58931953edb7c872b803cb261fce9 (patch) | |
tree | 35e118570baaefdc85faf34df0970f3fafdfae1f /ghc | |
parent | 120b9cdb31878ecee442c0a4bb9532a9d30c0c64 (diff) | |
download | haskell-6ca9b15f77e58931953edb7c872b803cb261fce9.tar.gz |
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
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 6 |
1 files changed, 4 insertions, 2 deletions
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) |