Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

modifyCache is the source of a space leak #1296

Closed
mpickering opened this issue Jun 17, 2019 · 0 comments · Fixed by #1305
Closed

modifyCache is the source of a space leak #1296

mpickering opened this issue Jun 17, 2019 · 0 comments · Fixed by #1305
Milestone

Comments

@mpickering
Copy link
Collaborator

Observe here that the result of applying f is not forced so repeated applications will
result in a chain of thunks.

One way to fix this is:

commit c3bdae0f7df63c8bdb4f360285feeb7eadff8966 (HEAD -> hie-bios, mpickering/hie-bios)
Author: Matthew Pickering <matthewtpickering@gmail.com>
Date:   Mon Jun 17 23:58:05 2019 +0100

    Fix module leaks

diff --git a/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs b/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs
index 3bf08aa5..e40ef193 100644
--- a/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs
+++ b/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs
@@ -61,7 +61,8 @@ import System.IO
 modifyCache :: (HasGhcModuleCache m) => (GhcModuleCache -> GhcModuleCache) -> m ()
 modifyCache f = do
   mc <- getModuleCache
-  setModuleCache (f mc)
+  let x = (f mc)
+  x `seq` setModuleCache x
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants