title: Visual Basic Winform - Bad performance when targeting build to AnyCPU/x64
body: <p>I'm facing a performance issue when building my winform project (.Net 4.0, Visual Studio 2012) using AnyCPU or x64 platform (release mode). My screen has around 500 controls (this is an old screen, including ListBox, Label, Panel, TextBox - just basic controls).</p>
  
  <p>In AnyCPU/x64 build, it takes 90 seconds to initialize all the controls (I put timer before and after InitializeComponent method in designer file; no event is fired during control initialization time). In x86 build, it only takes 2-3 seconds to initialize all the controls.</p>
  
  <p>All the 2 builds are in release mode. In debug mode, the performance is very good for both cases (2-3 seconds). My OS is Windows 7 64bit.</p>
  
  <p>I used VMMap to see the memory graph of the 2 builds. Looking at the graphs (at the bottom of this question), I got the result below</p>
  
  <p><strong>x86</strong></p>
  
  <ul>
  <li>Total (size): 356,172K</li>
  <li>Heap: 17,216K</li>
  <li>Managed Heap: 34,240K</li>
  <li>Stack: 17,920K</li>
  <li>Private Data: 21,232K</li>
  <li>Page Table: empty</li>
  <li>Free: 1,740,916</li>
  </ul>
  
  <p><strong>x64</strong></p>
  
  <ul>
  <li>Total (size): 841,200K</li>
  <li>Heap: 49,284</li>
  <li>Managed Heap: 397,632</li>
  <li>Stack: 61,440K</li>
  <li>Private Data: 23,000K</li>
  <li>Page Table: 952K</li>
  <li>Free: 8,589,094,280K</li>
  </ul>
  
  <p>There is no significant difference in Image, Mapped File, Shareable, Unusable.</p>
  
  <p>I'm a little surprised that the Managed Heap of x64 is very large in comparison to x86's. Also, when the form is loaded, the private data of x64 is up to 1GB, then down to MBs; whereas, no significant change in x86.</p>
  
  <p>Could you please help to explain me what could cause the difference in performance and data size? If you need more information, please let me know.</p>
  
  <p>Many Thanks</p>
  
  <p><img src="https://i.stack.imgur.com/8qN0f.png" alt="enter image description here"></p>