From 4008a2b1114983e0d98df157cf4b3bad2764ad52 Mon Sep 17 00:00:00 2001 From: hallgren Date: Thu, 10 Apr 2014 15:55:33 +0000 Subject: 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. --- src/server/Cache.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/server/Cache.hs') diff --git a/src/server/Cache.hs b/src/server/Cache.hs index d7c806783..bde07745a 100644 --- a/src/server/Cache.hs +++ b/src/server/Cache.hs @@ -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 -- cgit v1.2.3