title: Out of memory (?) problem on Win32 (vs. Linux)
body: <p>I have the following problem: </p>
  
  <p>A program run on a windows machine (32bit, 3.1Gb memory, both VC++2008 and mingw compiled code) fails with a <code>bad_alloc</code> exception thrown (after allocating around 1.2Gb; the exception is thrown when trying to allocate a vector of 9 million doubles, i.e. around 75Mb) with plenty of RAM still available (at least according to task manager). </p>
  
  <p>The same program run on linux machines (32bit, 4Gb memory; 32bit, 2Gb memory) runs fine with peak memory usage of around 1.6Gb. Interestingly the win32 code generated by mingw run on the 4Gb linux machine under wine also fails with a bad_alloc, albeit at a different (later) place then when run under windows...</p>
  
  <p>What are the possible problems?</p>
  
  <ul>
  <li>Heap fragmentation? (How would I know? How can this be solved?)</li>
  <li>Heap corruption? (I have run the code with pageheap.exe enabled with no errors reported; implemented vector access with bounds checking --- again no errors; the code is essentially free of pointers, only <code>std::vector</code>s and <code>std::list</code>s are used. Running
  the program under Valgrind (memcheck) consumes too much memory and ends prematurely, but does not find any errors)</li>
  <li>Out of memory??? (There should be enough memory)</li>
  </ul>
  
  <p>Moreover, what could be the reason that the windows version fails while the
  linux version works (and even on machines with less memory)? (Also note that
  the /LARGEADDRESSAWARE linker flag is used with VC+2008 if that can have any effect)</p>
  
  <p>Any ideas would be much appreciated, I am at my wits end with this... :-(</p>