2

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....

Community
  • 1
  • 1
  • Can you give a short example code, please? – Martin Zabel Dec 29 '15 at 18:19
  • updated the post with the code from the link. – buckleupbuckaroo Dec 29 '15 at 18:27
  • I've done very little with WINE, but this sounds like a [NUMA](https://en.m.wikipedia.org/wiki/Non-uniform_memory_access) issue to me. NUMA systems have the memory banks divided among the processors, and the OS, by default, may only allocate as much memory to a process as is connected to the processor where the requesting process is running... so a 16 core 128GB machine might have 4 cores each on 4 physical CPUs, hence a 32GB limit... but should be configurable. – Michael - sqlbot Dec 29 '15 at 22:36
  • @Michael-sqlbot: I took a look at the settings and played with a numactl command but it still did not work. Can you take a look at the Edit above? – buckleupbuckaroo Dec 30 '15 at 00:45
  • Yes, it looks like my guess was off-base. Apologies for that. I guess at least, now, you know one more thing that it isn't. :/ Not sure if `strace` might be usable, to see if wine is asking for more memory, and the system is denying it or if wine isn't bothering to ask, due to something internal, but that's the only other thought I have. – Michael - sqlbot Dec 30 '15 at 01:42

1 Answers1

1

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.