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

Fix some memory leaks #2876

Merged
merged 7 commits into from
Jul 18, 2017
Merged

Fix some memory leaks #2876

merged 7 commits into from
Jul 18, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jul 16, 2017

This is a series of commits to fix some memory leaks detected when using the IDE for some time.

My workflow is as follows:

  • Launch the IDE and attach YourKit to it.
  • Do some other activity (e.g. bug fixes)
  • Observe used memory go up
  • After some time do a memory snapshot
  • Find all instances of RunInfo (ideally, there should be only one, but currently there are many).
  • Calculate shortest paths back to some arbitrary previous RunInfo.
  • Find a place where we can break the path by changing some bit in the compiler. Typically,
    we want to avoid hanging onto a Context beyond the run where it was created.
  • Apply the changes.
  • Repeat.

odersky added 2 commits July 16, 2017 11:32
After setting the `inst` field of a TypeVar, the owningState is no longer needed.
Null it out in order to avoid a memory leak (TypeStates refer to constraints and
error logs and error logs can refer to contexts via unforced diagnostic messages).
odersky added 5 commits July 17, 2017 11:15
`owningState` of `TypeVar` was still a source of memory leaks even though
we null it out when a TypeVar gets instantiated. The problem is that uninstantiated
TypeVars can sit as parts of types in caches.
Message expressions usually capture contexts, which can cause space leaks
if an error type is stored in a retained tree.
In LambdaLift, fields used only in the constructor of a class should not be marked
free in the enclosing class.
@odersky odersky merged commit b3dd94f into scala:master Jul 18, 2017
@allanrenucci allanrenucci deleted the fix-leaks branch December 14, 2017 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants