- 1 year ago
Force heap allocations above 4 GB
Comment
1 / 1
To force heap allocations above the 4 GB limit on a 64-bit Windows system, you can use the /LARGEADDRESSAWARE
linker flag when compiling your application. This flag enables the application to use the full 64-bit address space, allowing heap allocations above the default 4 GB limit.
Here's how you can enable the /LARGEADDRESSAWARE
flag in various development environments:
Visual Studio:
- Open your project in Visual Studio.
- Right-click on your project in the Solution Explorer and select "Properties".
- In the project properties window, navigate to "Configuration Properties" > "Linker" > "System".
- Set the "Enable Large Addresses" property to "Yes (/LARGEADDRESSAWARE)".
GCC (MinGW):
- When compiling your application using GCC, add the
-Wl,--large-address-aware
flag to the linker command line.
CMake:
- In your CMakeLists.txt file, add the following line to enable the
/LARGEADDRESSAWARE
flag:bashset(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
By enabling the /LARGEADDRESSAWARE
flag, your application will have access to the full 64-bit address space, allowing heap allocations above 4 GB. Keep in mind that this flag only works on 64-bit systems, and it should be used with caution, as it may have compatibility implications with certain libraries or dependencies.