Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a 32bit process access more memory on a 64bit windows OS?

From what I understand, a 32-bit process can only access 2 GB of memory on 32-bit Windows without the /3GB switch, and that some of that memory is taken up by the OS for its own diabolical reasons. This seems to mesh with my experience as we have an app that crashes when it reaches around 1.2 - 1.5 GB of RAM without memory exceptions, even though there is still plenty of memory available.

Would moving this 32-bit application to 64-bit Windows allowing it accesses more than 1.5 GB it can now? Would the application itself have to be upgraded to 64-bit?

like image 886
Ely Avatar asked Feb 20 '09 17:02

Ely


4 Answers

Newer versions of Visual Studio have a new flag which make 32-bit apps "big address space aware". Basically what it does is say that if it's loaded on a 64-bit version of windows, then it will get 4GB (the limit of 32-bit pointers). This is certainly better than the 2 or 3 GB you get on 32-bit versions of windows. See http://msdn.microsoft.com/en-us/library/aa366778.aspx:

Most notably it says:

Limits on memory and address space vary by platform, operating system, and by whether the IMAGE_FILE_LARGE_ADDRESS_AWARE value of the LOADED_IMAGE structure and 4-gigabyte tuning (4GT) are in use. IMAGE_FILE_LARGE_ADDRESS_AWARE is set or cleared by using the /LARGEADDRESSAWARE linker option.

Also see: http://msdn.microsoft.com/en-us/library/wz223b1z.aspx

like image 72
Evan Teran Avatar answered Oct 13 '22 04:10

Evan Teran


Yes, under the right circumstances, a 32-bit process on Windows can access a full 4GB of memory, rather than the 2Gb it's normally limited to.

For this to work, you need the following:

  • The app must be running on a 64-bit OS
  • The app must be compiled with the /LARGEADDRESSAWARE flag.
  • The app should be tested to make sure it actually works properly in this case. ;) (specifically, code that relies on all pointers pointing to addresses below the 2GB boundary will obviously not work here)
like image 43
jalf Avatar answered Oct 13 '22 05:10

jalf


Your app will be limited by the pointer size, in your example 32 bits.

If your app was to access more memory then you would need some sort of segmented memory architecture like we had in the 16 bit days where apps used 16bit pointers and offsets to access the full 32bit memory space.

like image 36
chollida Avatar answered Oct 13 '22 05:10

chollida


WOW64 allows using 32-bit Windows application on 64-bit Windows, translating 32-bit pointers to real 64-bit pointers. And actually 32-bit addressing should allow accessing 4GB of memory.

like image 24
vartec Avatar answered Oct 13 '22 04:10

vartec