Skip to content

Commit

Permalink
fixed space leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
krangelov committed Apr 6, 2024
1 parent 6126d36 commit 81717e7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/compiler/api/GF/Interactive.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE CPP, ScopedTypeVariables, FlexibleInstances #-}
{-# LANGUAGE CPP, ScopedTypeVariables, FlexibleInstances, BangPatterns #-}
-- | GF interactive mode
module GF.Interactive (mainGFI,mainRunGFI,mainServerGFI) where

Expand Down Expand Up @@ -262,7 +262,8 @@ pwords s = case words s of
import_ readNGF args =
do case parseOptions args of
Ok (opts',files) -> do
opts <- gets startOpts
!opts <- gets startOpts -- use a bang to avoid retaining a reference to the old state,
-- otherwise we leak references to PGF revisions.
curr_dir <- lift getCurrentDirectory
lib_dir <- lift $ getLibraryDirectory (addOptions opts opts')
importInEnv readNGF (addOptions opts (fixRelativeLibPaths curr_dir lib_dir opts')) files
Expand Down Expand Up @@ -448,7 +449,7 @@ importInEnv readNGF opts files =
(RetainSource,mb_txn) -> do src <- lift $ importSource opts pgf0 files
modify $ \gfenv -> gfenv{pgfenv = (snd src,pgf0,mb_txn)}
(RetainCompiled,Nothing) -> do pgf <- lift $ importPGF pgf0
src <- lift $ importSource opts pgf ["prelude/Predef.gfo"]
src <- lift $ importSource opts Nothing ["prelude/Predef.gfo"]
modify $ \gfenv -> gfenv{pgfenv = (snd src,pgf,Nothing)}
_ -> fail "You must commit/rollback the transaction before loading a new grammar"
where
Expand Down

0 comments on commit 81717e7

Please sign in to comment.