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

Lazy values should null out fields that are no longer needed #720

Closed
scabug opened this issue Apr 3, 2008 · 4 comments
Closed

Lazy values should null out fields that are no longer needed #720

scabug opened this issue Apr 3, 2008 · 4 comments
Assignees

Comments

@scabug
Copy link

scabug commented Apr 3, 2008

Consider the following case:

   class Foo(f : => Unit){
      lazy val bar = f;
   }

Once bar has been evaluated, f is no longer needed, but instances of Foo will retain a reference to it anyway (and anything it in turn has captured), potentially preventing all sorts of things from being garbage collected. This is bad, and will become particularly important once #240 is done and we have lazy parameters.

It would be nice if the following was also handled correctly:

   class Foo(f : => Unit){
      lazy val bar = f;
      lazy val baz = f;
   }

But this is somewhat less important and handling the case of only one lazy val will probably capture most of the use cases.

@scabug
Copy link
Author

scabug commented Apr 3, 2008

Imported From: https://issues.scala-lang.org/browse/SI-720?orig=1
Reporter: @DRMacIver
See #240

@scabug
Copy link
Author

scabug commented Apr 3, 2008

@DRMacIver said:
Sorry, #240 rathe than #204

@scabug
Copy link
Author

scabug commented Jan 14, 2009

@odersky said:
Milestone postponed deleted

@scabug
Copy link
Author

scabug commented Sep 28, 2009

@dragos said:
Fixed in r18813, by taking care of the simplest case: private fields that are used in exactly one lazy value (and nowhere else) are set to null. The example give here: http://thread.gmane.org/gmane.comp.lang.scala.user/899/focus=900 works fine now.

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

No branches or pull requests

2 participants