static events; DEADLY, since they never go out of scope.
static event EventHandler Evil;
for(int i = 0 ; i < 1000000 ; i++)
Evil += delegate {};
The anonymous method is simply a nice-to-have here but are nice because they also are a pig to unsubscribe unless you take a copy into a variable/field and subscribe that.
Technically this isn't actually "leaked", as you can still access them via Evil.GetInvocationList()
- however, when used with regular objects this can cause unexpected object lifetimes, i.e.
MyHeavyObject obj = ...
...
SomeType.SomeStaticEvent += obj.SomeMethod;
now the object at obj
lives forever. This satisfies enough of a perceived leak IMO, and "my app died a horrible death" is good enough for me ;p