Does lamda in List.ForEach leads to memory leaks and performance problems ?
Posted
by Monomachus
on Stack Overflow
See other posts from Stack Overflow
or by Monomachus
Published on 2010-05-12T11:54:24Z
Indexed on
2010/05/12
12:04 UTC
Read the original article
Hit count: 237
I have a problem which I could solve using something like this
sortedElements.ForEach((XElement el) => PrintXElementName(el,i++));
And this means that I have in ForEach a lambda which permits using parameters like int i.
I like that way of doing it, but i read somewhere that anonymous methods and delegates with lambda leads to a lot of memory leaks because each time when lambda is executed something is instantiated but is not released. Something like that.
Could you please tell me if this is true in this situation and if it is why?
© Stack Overflow or respective owner