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
Optimizer removes assignment too eagerly => memory leaks? #5313
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5313?orig=1 |
@VladUreche said: |
@JamesIry said: def foo = {
var x = new HumungoObject
// use x
x = new SmallObject
blah()
} The reassignment to x frees up the reference to the HumungoObject, making it elligible for gc and freeing up memory for blah() to work. Maybe there are some heuristics we could use like eliminating a local store that's the last instruction of a method before a return or some such. But whatever we come up with is bound to catch relatively few cases and probably won't be worth the effort. |
@JamesIry said: |
@JamesIry said: Devil. Details. |
@VladUreche said (edited on Jan 25, 2013 9:19:51 PM UTC): |
@paulp said: |
@JamesIry said: I have a version that replaces the unneeded store with null. I think I'd rather put that in 2.11 than 2.10. |
@JamesIry said: |
@JamesIry said: |
The null assignment in the following snippet is removed when compiled with -optimise which leads to different behavior and can result in memory leaks. It seems to be a bit of an edge case, since obj is a local var, but it is surprising nonetheless. I actually encountered this in a unit test testing for leaks, where a setup like below can be common.
The text was updated successfully, but these errors were encountered: