Advertisement
Guest User

Untitled

a guest
Jul 8th, 2011
1,472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. //Original code
  2. namespace ConsoleApplication4
  3. {
  4.     class Program
  5.     {
  6.         static Action F()
  7.         {
  8.             var d = new Dictionary<string, string>();
  9.             var freakingLargeDictionary = new Dictionary<string, string>();
  10.  
  11.             //Filling our freakingLargeDictionary with some random data.
  12.  
  13.             var a1 = new Action(() => { d.Add("a1", "a1"); freakingLargeDictionary.Add("a1", "a1"); });
  14.             var a2 = new Action(() => { d.Add("a2", "a2"); });
  15.  
  16.             return a2;
  17.         }
  18.  
  19.         static void Main(string[] args)
  20.         {
  21.             //You've just captured a couple of useless gigabytes with "a", right?
  22.             var a = F();
  23.         }
  24.     }
  25. }
  26.  
  27. //Disassembly
  28. namespace ConsoleApplication4
  29. {
  30.     internal class Program
  31.     {
  32.         [CompilerGenerated]
  33.         private sealed class <>c__DisplayClass2
  34.         {
  35.             public Dictionary<string, string> d;
  36.             public Dictionary<string, string> freakingLargeDictionary;
  37.             public void <F>b__0()
  38.             {
  39.                 this.d.Add("a1", "a1");
  40.                 this.freakingLargeDictionary.Add("a1", "a1");
  41.             }
  42.             public void <F>b__1()
  43.             {
  44.                 this.d.Add("a2", "a2");
  45.             }
  46.         }
  47.         private static Action F()
  48.         {
  49.             Program.<>c__DisplayClass2 <>c__DisplayClass = new Program.<>c__DisplayClass2();
  50.             <>c__DisplayClass.d = new Dictionary<string, string>();
  51.             <>c__DisplayClass.freakingLargeDictionary = new Dictionary<string, string>();
  52.             Action a = new Action(<>c__DisplayClass.<F>b__0);
  53.             return new Action(<>c__DisplayClass.<F>b__1);
  54.         }
  55.         private static void Main(string[] args)
  56.         {
  57.             Action a = Program.F();
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement