Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space leak in persistentHieFileRule #1946

Open
pepeiborra opened this issue Jun 18, 2021 · 3 comments
Open

Space leak in persistentHieFileRule #1946

pepeiborra opened this issue Jun 18, 2021 · 3 comments
Labels
performance Issues about memory consumption, responsiveness, etc. type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@pepeiborra
Copy link
Collaborator

(currentSource,ver) <- liftIO $ do
mvf <- getVirtualFile vfs $ filePathToUri' file
case mvf of
Nothing -> (,Nothing) . T.decode encoding <$> BS.readFile (fromNormalizedFilePath file)
Just vf -> pure (Rope.toText $ _text vf, Just $ _lsp_version vf)
let refmap = generateReferencesMap . getAsts . hie_asts $ res
del = deltaFromDiff (T.decode encoding $ hie_hs_src res) currentSource
pure (HAR (hie_module res) (hie_asts res) refmap mempty (HieFromDisk res),del,ver)

del in line 512 keeps two large byte strings alive:

  • source code of the .hs file on disk
  • source code recorded in the .hie file

This is leaked for all the modules in the project with an entry in the hiedb and a .hie file (all in most circumstances).

The memory leak is not flushed until the HieAstResult is actually used and the PositionMapping is forced.

@jneira jneira added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. performance Issues about memory consumption, responsiveness, etc. labels Jun 18, 2021
@pepeiborra pepeiborra changed the title Memory leak in persistentHieFileRule Space leak in persistentHieFileRule Jun 18, 2021
@pepeiborra
Copy link
Collaborator Author

persistentHieFile is only used at startup to load data before the build graph has been initialised, and the results it provides will be short-lived (hopefully) so I'm not sure how much this is an issue in practice.

@jneira
Copy link
Member

jneira commented Jan 31, 2022

This continue being a problem after the perf improvements post-1.4.0?

@michaelpj
Copy link
Collaborator

@wz1000 is this still a problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Issues about memory consumption, responsiveness, etc. type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

3 participants