Wine memory limitation for malloc?
Wine memory limitation for malloc?
Why win32 application under Wine can allocate only 2000 MB of memory, but same programm translated by gcc can get 3800 MB.
(OS/Compilers - WinXP/Visual C 6.0 32 bit, and openSUSE 11 x64/gcc -m32)
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
main(int argc, char **argv)
{unsigned long n,m,i; int *p;
i=4095; if (argc == 2) i = (size_t) strtoul(argv[1], NULL, 0);
m=i*1024*1024; while( (p=(int*)malloc(m)) ==0 ) m-=1024l*1024l;
printf("Allocated %u MB ( %u bytes )\n",m/1024l/1024l,m);
getchar(); free(p); exit(0);
}
(OS/Compilers - WinXP/Visual C 6.0 32 bit, and openSUSE 11 x64/gcc -m32)
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
main(int argc, char **argv)
{unsigned long n,m,i; int *p;
i=4095; if (argc == 2) i = (size_t) strtoul(argv[1], NULL, 0);
m=i*1024*1024; while( (p=(int*)malloc(m)) ==0 ) m-=1024l*1024l;
printf("Allocated %u MB ( %u bytes )\n",m/1024l/1024l,m);
getchar(); free(p); exit(0);
}
Re: Wine memory limitation for malloc?
Correct, that's all you get with 32-bit windows. Everything else reserved for the system.Adept wrote:Why win32 application under Wine can allocate only 2000 MB of memory,
Wine memory limitation for malloc?
On Tue, Jul 22, 2008 at 7:18 AM, vitamin <[email protected]> wrote:
http://www.microsoft.com/whdc/system/pl ... AEmem.mspx
Gert van den Berg
Actually up to 3GB in certain cases under Windows NT 5.x...Adept wrote:Correct, that's all you get with 32-bit windows. Everything else reserved for the system.Why win32 application under Wine can allocate only 2000 MB of memory,
http://www.microsoft.com/whdc/system/pl ... AEmem.mspx
Gert van den Berg
Re: Wine memory limitation for malloc?
BTW, PAE options supported and Windows XP.Gert van den Berg wrote:On Tue, Jul 22, 2008 at 7:18 AM, vitamin <[email protected]> wrote:Actually up to 3GB in certain cases under Windows NT 5.x...Adept wrote:Correct, that's all you get with 32-bit windows. Everything else reserved for the system.Why win32 application under Wine can allocate only 2000 MB of memory,
http://www.microsoft.com/whdc/system/pl ... AEmem.mspx
Gert van den Berg
I think, it's bad idea for Wine, to emulate Windows limitations.
If Wine+linux can give more memory to my application, it's good reason (for me, as Windows user) to format Windows and install Linux+Wine.
There are apps that won't work if there is more than 2GB memory (e.g. they may treat this value as signed and fail to start informing the user that it requires at least 16MB of RAM on a computer with 3GB RAM). That's why Microsoft introduced a header flag that allows the developer to mark the executable as able to handle such an amount of memory. Wine also implements this behaviour. When compiling the program with Visual C, you should try the linker option /LARGEADDRESSAWARE:YES . AFAIK this puts that flag in the header.
As it was said, on 32-bit Windows, in the default configuration, this flag won't change anything as the high 2GB of address space is reserved for the system (and it's not possible to allocate more memory with malloc than the available address space). It's possible to make 3GB of address space available to the application with the /3gb switch in boot.ini. AFAIR, the 3GB address space is the default on Linux and may be even increased by distributions. On 64-bit Windows and Linux, the whole 4GB of address space will be visible to applicaitons with such a flag.
I may also add that this problem is different than the problem addressed by the PAE. The PAE allows to give more than 4GB of physical memory to all the processes in the system. The problem here is how much of the address space is available to a single process.
As it was said, on 32-bit Windows, in the default configuration, this flag won't change anything as the high 2GB of address space is reserved for the system (and it's not possible to allocate more memory with malloc than the available address space). It's possible to make 3GB of address space available to the application with the /3gb switch in boot.ini. AFAIR, the 3GB address space is the default on Linux and may be even increased by distributions. On 64-bit Windows and Linux, the whole 4GB of address space will be visible to applicaitons with such a flag.
I may also add that this problem is different than the problem addressed by the PAE. The PAE allows to give more than 4GB of physical memory to all the processes in the system. The problem here is how much of the address space is available to a single process.
It's great idea!mikolajz wrote:There are apps that won't work if there is more than 2GB memory (e.g. they may treat this value as signed and fail to start informing the user that it requires at least 16MB of RAM on a computer with 3GB RAM). That's why Microsoft introduced a header flag that allows the developer to mark the executable as able to handle such an amount of memory. Wine also implements this behaviour. When compiling the program with Visual C, you should try the linker option /LARGEADDRESSAWARE:YES . AFAIK this puts that flag in the header.
As it was said, on 32-bit Windows, in the default configuration, this flag won't change anything as the high 2GB of address space is reserved for the system (and it's not possible to allocate more memory with malloc than the available address space). It's possible to make 3GB of address space available to the application with the /3gb switch in boot.ini. AFAIR, the 3GB address space is the default on Linux and may be even increased by distributions. On 64-bit Windows and Linux, the whole 4GB of address space will be visible to applicaitons with such a flag.
I may also add that this problem is different than the problem addressed by the PAE. The PAE allows to give more than 4GB of physical memory to all the processes in the system. The problem here is how much of the address space is available to a single process.
Test program:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
main(int argc, char **argv)
{unsigned long n,m,N,i; int *p,*p1,*p2,*p3; clock_t time1,time2;
i=4095; if (argc == 2) i = (size_t) strtoul(argv[1], NULL, 0); n=0; N=0;
m=i*1024*1024; while( (p=(int*)malloc(m)) ==0 ) m-=1024l*1024l;
printf("Allocated %u MB ( %u bytes )\n",m/1024l/1024l,m); n=m; N=m;
m=i*1024*1024; while( (p1=(int*)malloc(m)) ==0 ) m-=1024l*1024l;
printf("Allocated %u MB ( %u bytes )\n",m/1024l/1024l,m); N+=m;
m=i*1024*1024; while( (p2=(int*)malloc(m)) ==0 ) m-=1024l*1024l;
printf("Allocated %u MB ( %u bytes )\n",m/1024l/1024l,m); N+=m;
m=i*1024*1024; while( (p3=(int*)malloc(m)) ==0 ) m-=1024l*1024l;
printf("Allocated %u MB ( %u bytes )\n",m/1024l/1024l,m); N+=m;
printf("Total allocated %u MB ( %u bytes )\n",N/1024l/1024l,m);
}
Results:
Computer: Core 2Duo, 4GB physical memory.
OS - openSUSE 11 x64.
Win32 console application compiled _without_ linker option /LARGEADDRESSAWARE. Visual C 6.0. Started under wineconsole.
Allocated 1529 MB
Allocated 439 MB
Allocated 45 MB
Allocated 15 MB
Total allocated 2028 MB
Win32 console application compiled with linker option /LARGEADDRESSAWARE. Visual C 6.0. Started under wineconsole.
Allocated 1529 MB
Allocated 1024 MB
Allocated 439 MB
Allocated 45 MB
Total allocated 3037 MB
Linux 32-bit application compiled gcc with option -m32
Allocated 3836 MB
Allocated 128 MB
Allocated 123 MB
Allocated 4 MB
Total allocated 4091 MB
Good option /LARGEADDRESSAWARE, but 1GB unused

Quote from wine sources. File vxd.c:
>> /*
>> * Note: Win32s reserves 0GB - 2GB for Win 3.1 and uses 2GB - 4GB as
>> * sparse memory arena. We do it the other way around, since
>> * we have to reserve 3GB - 4GB for Linux, and thus use
>> * 0GB - 3GB as sparse memory arena.
>> *
>> * FIXME: What about other OSes ?
>> */
>> context->Ecx = W32S_WINE2APP(0x00000000);
>> context->Edx = W32S_WINE2APP(0xbfffffff);
1GB reserve for Lunix?! IMHO, not more 256MB!
The comment in vxd.c is old and so it Win32s. The important part is in dlls/ntdll/virtual.c - there is there an ADDRESS_SPACE_LIMIT of 3GB. There is a comment that this is a Windows limit, but AFAIK it is not present on x64 Windows, so probably it can be changed for LARGE_ADDRESS_AWARE programs, to allow them to use all the address space. Maybe we should query the host OS for it?
You could try to compile Wine with this limit set to 0 and check if this help with your program.
You could try to compile Wine with this limit set to 0 and check if this help with your program.
Wine memory limitation for malloc?
On Tue, Jul 22, 2008 at 12:42 PM, mikolajz <[email protected]> wrote:
know Wine complains if they are changed...
Just a note: If I remember correctly Linux x86 can use the full 64GB
supported by PAE, with a smaller per-process limit... (x86_64 supports
a lot more off course...)
all processes) even if PAE is enabled since Service Pack 2...
http://support.microsoft.com/kb/888137
I wonder if the CONFIG_VMSPLIT* options in the kernel is relevant? IAs it was said, on 32-bit Windows, in the default configuration, this flag won't change anything as the high 2GB of address space is reserved for the system (and it's not possible to allocate more memory with malloc than the available address space). It's possible to make 3GB of address space available to the application with the /3gb switch in boot.ini. AFAIR, the 3GB address space is the default on Linux and may be even increased by distributions. On 64-bit Windows and Linux, the whole 4GB of address space will be visible to applicaitons with such a flag.
know Wine complains if they are changed...
Just a note: If I remember correctly Linux x86 can use the full 64GB
supported by PAE, with a smaller per-process limit... (x86_64 supports
a lot more off course...)
Windows XP x86 will not use the full 4GB (as a total address space forI may also add that this problem is different than the problem addressed by the PAE. The PAE allows to give more than 4GB of physical memory to all the processes in the system. The problem here is how much of the address space is available to a single process.
all processes) even if PAE is enabled since Service Pack 2...
http://support.microsoft.com/kb/888137
It's written in a comment that this 3GB limit is a Windows limit, so maybe it's from the the Win9x memory layout (http://support.microsoft.com/kb/q125691/). I don't know why the 3GB would be special in the NT memory layout. I would need to check that but I think we can change this in NT mode. It would be best to take the vmsplit value from the kernel, but I don't know yet how it can be queried at runtime.
It's getting a bit off-topis, but AFAIK the PAE was enabled in SP2 only because it is required to use the NX bit (no-execute memory, a.k.a. XD, DEP). To have true PAE support you need to have Windows Server Enterprise (or a 64-bit OS).Windows XP x86 will not use the full 4GB (as a total address space for
all processes) even if PAE is enabled since Service Pack 2...
Great! It's work!mikolajz wrote:The comment in vxd.c is old and so it Win32s. The important part is in dlls/ntdll/virtual.c - there is there an ADDRESS_SPACE_LIMIT of 3GB. There is a comment that this is a Windows limit, but AFAIK it is not present on x64 Windows, so probably it can be changed for LARGE_ADDRESS_AWARE programs, to allow them to use all the address space. Maybe we should query the host OS for it?
You could try to compile Wine with this limit set to 0 and check if this help with your program.
I change in dlls/ntdll/virtual.c two lines:
# define ADDRESS_SPACE_LIMIT ((void *)0xc0000000) /* top of the total available address space */
# define USER_SPACE_LIMIT ((void *)0x7fff0000) /* top of the user address space */
to
# define ADDRESS_SPACE_LIMIT 0 /* no limit needed on other platforms */
# define USER_SPACE_LIMIT 0 /* no limit needed on other platforms */
and compile Wine. As a result it possible to allocate about 3600 MB for windows application (openSUSE x64 +Wine 1.0)
Do I need x64 Linux, or need to change more? When I change just what's listed on i686 bigmem, I get
Thanks for any help.
Code: Select all
make[2]: Entering directory `/home/username/Desktop/wine-1.1.2/dlls/ntdll'
gcc -c -I. -I. -I../../include -I../../include -D__WINESRC__ -D_NTSYSTEM_ -D_RE ENTRANT -fPIC -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Ww rite-strings -Wtype-limits -Wpointer-arith -g -O2 -o actctx.o actctx.c
actctx.c: In function ‘RtlQueryInformationActivationContext’:
actctx.c:2620: internal compiler error: Segmentation fault
Unlikely. Wine conforms to what windows does and it's limitations, or it will break LOTS of applications.downer wrote:(Debian Testing with gcc 4.3)
Will larger memory support be standard with Wine in the future? I only ask because I don't want to go back to Windows just for larger memory support.
Also Wine is NOT 64-bit and won't be in the near future.
That's compile problem not Wine. You most likely needdowner wrote:actctx.cinternal compiler error: Segmentation fault[/code]
Thanks for any help.
Code: Select all
ulimit -u unlimited
IMHO, it's possible to make some user defined option for skip memory limits. For example:vitamin wrote:Unlikely. Wine conforms to what windows does and it's limitations, or it will break LOTS of applications.downer wrote:(Debian Testing with gcc 4.3)
Will larger memory support be standard with Wine in the future? I only ask because I don't want to go back to Windows just for larger memory support.
Also Wine is NOT 64-bit and won't be in the near future.
$ wine -BIG_MEM myprog.exe