mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-03 08:12:51 -06:00
PGF web service: disable caching of parse results
Caching parse results uses a lot of memory, even if they expire after 2 minutes, so it won't scale up to many simultaneous users. But some excessive memory use seems to be caused by space leaks in (the Haskell binding to) the C run-time system, and these should be fixed. For example, flushing the PGF cache does not release the memory allocated by the C run-time system when loading a PGF file.
This commit is contained in:
@@ -4,6 +4,7 @@ import Control.Concurrent.MVar
|
||||
import Data.Map (Map)
|
||||
import qualified Data.Map as Map
|
||||
import System.Directory (getModificationTime)
|
||||
import System.Mem(performGC)
|
||||
import Data.Time (UTCTime)
|
||||
import Data.Time.Compat (toUTCTime)
|
||||
|
||||
@@ -18,7 +19,8 @@ newCache load =
|
||||
return $ Cache { cacheLoad = load, cacheObjects = objs }
|
||||
|
||||
flushCache :: Cache a -> IO ()
|
||||
flushCache c = modifyMVar_ (cacheObjects c) (const (return Map.empty))
|
||||
flushCache c = do modifyMVar_ (cacheObjects c) (const (return Map.empty))
|
||||
performGC
|
||||
|
||||
readCache :: Cache a -> FilePath -> IO a
|
||||
readCache c file = snd `fmap` readCache' c file
|
||||
|
||||
Reference in New Issue
Block a user