Q:

Wine can't use more than 32GB of RAM on Ubuntu Amazon EC2

I am having issues mallocing more than 32GB of memory running RAM intensive Windows applications using Wine on an Ubuntu amazon EC2 cloud with 128 GB of RAM.  When I run the c++ code here in linux it works.
If I run the .exe that does the same thing I can only allocate up to 32GB. I tried Wine 1.6, 1.7 and 1.9. I am using the 64 bit version as well. Any thoughts?
#include <stdlib.h>
#include <iostream>

int main()
{
   size_t gb_in_bytes = size_t(1)<<size_t(30); // 1 GB in bytes (2^30).
   // try to allocate 1 block of 'i' GB.
   for (size_t i = 25; i < 35; ++ i) {
      size_t n = i * gb_in_bytes;
      void *p = ::malloc(n);
      std::cout << "allocation of 1 x " << (n/double(gb_in_bytes)) << " GB of data. Ok? " << ((p==0)? "nope" : "yes") << std::endl;
      ::free(p);
   }
}

EDIT
I tried playing the settings for NUMA using the suggestions on Mongo's site.
numactl --interleave=all wine test.exe

But this did not help. Here is a dump of my NUMA settings on the server:
$ numactl --hardware
available: 2 nodes (0-1)
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 20 21 22 23 24 25 26 27 28 29
node 0 size: 80555 MB
node 0 free: 75980 MB
node 1 cpus: 10 11 12 13 14 15 16 17 18 19 30 31 32 33 34 35 36 37 38 39
node 1 size: 80631 MB
node 1 free: 79686 MB
node distances:
node   0   1
  0:  10  20
  1:  20  10

and it looks like I have well over 32GB of memory per node....

A:

Thanks to the tip by Alexandre Julliard, I was able to modify the VIRTUAL_HEAP_SIZE constant in dlls/ntdll/virtual.c to be 2x larger. 
Alexandre stated:

The virtual heap is running out of space. Storing the page protection flags for 32Gb requires 8Mb, which is the heap limit. You can increase VIRTUAL_HEAP_SIZE in dlls/ntdll/virtual.c to work around it, but we probably want a different mechanism for such cases.

I made the change in line 144 in dlls/ntdll/virtual.c:
#define VIRTUAL_HEAP_SIZE (sizeof(void*)*1024*1024)

to this:
#define VIRTUAL_HEAP_SIZE (sizeof(void*)*1024*1024*2)

locally in my wine source (version 1.9.0) and recompiled. This solved my issue. 

