When i pass a lambda expression or an anonymous function as a param, which will keep an implicit reference of the enclosing class. The situation may lead to memory leaks.
So, Kotlin may need something like WeakReference in java for function type can solve this problem.
like this:
fun foo(weak body: () -> Unit){
// we check here if body is still alive
body?()
}
I am not sure it is the best implementation, but is cool if i we can use it in kotlin.