Working with some funcional programming, I started wondering how does the garbage collector behaves with function/method references (for C# and Python's GC).
Let object A be an instance of a class with a method foo() and object B be an instance of a class with a field keeping a reference to object A's foo() method. Suposing that there is no other object referencing object A other than object B's method reference, will object A be collected by the garbage collector?
And how this scenario behaves with lambda functions?
question from:
https://stackoverflow.com/questions/65929367/can-a-function-reference-avoid-garbage-collection 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…