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:
hallgren
2014-04-10 15:55:33 +00:00
parent 5f75baf56a
commit 4008a2b111
2 changed files with 18 additions and 8 deletions

View File

@@ -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