First draft of translation document

Brian Goetz brian.goetz at oracle.com
Tue May 18 07:03:20 PDT 2010


> Just a note on section "10. Multiple lambdas per scope". While this
> approach is logically correct and optimizes the number of Objects
> created/classes used, it has a drawback that it might introduce memory
> leaks. A long-lived lambda might hold on to the references that it didn't
> actually capture in the source code.

Yes, this is certainly a risk.  Another similar risk is treating instance 
(reference) field capture as a capture of the final 'this' reference rather 
than simply capturing only the relevant reference fields.

Like everything else, there is a tradeoff to be made -- potentially pinning 
more objects in memory vs reducing the cost of lambda capture.



More information about the lambda-dev mailing list