Sometimes you want to pass an objects function as an argument and store that function (along its arguments) for later calling. Still you don’t want that storage to prevent its object (instance) from being destroyed (from being removed by the garbage collector). But storing a function does so, because it holds a reference to the function which belongs to an object.

It’s one of the biggest traps you can fall into when developing a larger project where many objects are created and destroyed and created and so on… geeks call that kind of thing memory leaks I think :)

So if you can avoid it: avoid it! If you can’t.. may be this little thing can help:
(more…)