Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Original code
- namespace ConsoleApplication4
- {
- class Program
- {
- static Action F()
- {
- var d = new Dictionary<string, string>();
- var freakingLargeDictionary = new Dictionary<string, string>();
- //Filling our freakingLargeDictionary with some random data.
- var a1 = new Action(() => { d.Add("a1", "a1"); freakingLargeDictionary.Add("a1", "a1"); });
- var a2 = new Action(() => { d.Add("a2", "a2"); });
- return a2;
- }
- static void Main(string[] args)
- {
- //You've just captured a couple of useless gigabytes with "a", right?
- var a = F();
- }
- }
- }
- //Disassembly
- namespace ConsoleApplication4
- {
- internal class Program
- {
- [CompilerGenerated]
- private sealed class <>c__DisplayClass2
- {
- public Dictionary<string, string> d;
- public Dictionary<string, string> freakingLargeDictionary;
- public void <F>b__0()
- {
- this.d.Add("a1", "a1");
- this.freakingLargeDictionary.Add("a1", "a1");
- }
- public void <F>b__1()
- {
- this.d.Add("a2", "a2");
- }
- }
- private static Action F()
- {
- Program.<>c__DisplayClass2 <>c__DisplayClass = new Program.<>c__DisplayClass2();
- <>c__DisplayClass.d = new Dictionary<string, string>();
- <>c__DisplayClass.freakingLargeDictionary = new Dictionary<string, string>();
- Action a = new Action(<>c__DisplayClass.<F>b__0);
- return new Action(<>c__DisplayClass.<F>b__1);
- }
- private static void Main(string[] args)
- {
- Action a = Program.F();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement