From 81717e782240cb9daff27c85e675ef5f1babfe91 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Sat, 6 Apr 2024 10:59:37 +0200 Subject: [PATCH] fixed space leaks --- src/compiler/api/GF/Interactive.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/api/GF/Interactive.hs b/src/compiler/api/GF/Interactive.hs index 2ba7c0813..59d5df5b1 100644 --- a/src/compiler/api/GF/Interactive.hs +++ b/src/compiler/api/GF/Interactive.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE CPP, ScopedTypeVariables, FlexibleInstances #-} +{-# LANGUAGE CPP, ScopedTypeVariables, FlexibleInstances, BangPatterns #-} -- | GF interactive mode module GF.Interactive (mainGFI,mainRunGFI,mainServerGFI) where @@ -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 @@ -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