digitalmars.D - OPTLINK and LARGEADDRESSAWARE
- Vladimir Panteleev (34/34) Apr 15 2009 Hi,
- Robert Fraser (2/42) Apr 15 2009 Awesome simple hack; thanks!
- Walter Bright (1/1) Apr 15 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2837
- torhu (2/7) Apr 15 2009 And for those with msvc installed, editbin.exe supports setting this fla...
Hi, It seems that OPTLINK doesn't support the IMAGE_FILE_LARGE_ADDRESS_AWARE flag (enabled with /LARGEADDRESSAWARE when using Microsoft Link), even though the D runtime seems to support it. Consider this simple program: ----------------------------- import std.stdio; void main() { ubyte[][4096] a; // GC anchor for (int i=0;;i++) { writefln(i); a[i].length = 1024*1024; } } ----------------------------- This program crashes when it tries to allocate the 1618th megabyte, even though my PC has 6 GB of RAM and the 32-bit address space allows for much more. I've patched the executable and enabled the IMAGE_FILE_LARGE_ADDRESS_AWARE flag. This flag is 0x0020 in the "Characteristics" field in the IMAGE_FILE_HEADER structure. In OPTLINK-generated executables, one can enable this flag manually by changing byte 0x76 from 0x8E to 0xAE in the executable file. The result - the program can now allocate 3319 megabytes on my machine, thus practically doubling its address space. (Why is it still not anywhere near the theoretical limit?) I've patched my copy of the linker until the official linker is updated. If anyone wants to use more than 2 (or 1.6?) GB in their DMD/Windows programs, change the byte at 0x3CF0D in link.exe from 0x8F to 0xAF. -- Best regards, Vladimir mailto:thecybershadow gmail.com
Apr 15 2009
Vladimir Panteleev wrote:Hi, It seems that OPTLINK doesn't support the IMAGE_FILE_LARGE_ADDRESS_AWARE flag (enabled with /LARGEADDRESSAWARE when using Microsoft Link), even though the D runtime seems to support it. Consider this simple program: ----------------------------- import std.stdio; void main() { ubyte[][4096] a; // GC anchor for (int i=0;;i++) { writefln(i); a[i].length = 1024*1024; } } ----------------------------- This program crashes when it tries to allocate the 1618th megabyte, even though my PC has 6 GB of RAM and the 32-bit address space allows for much more. I've patched the executable and enabled the IMAGE_FILE_LARGE_ADDRESS_AWARE flag. This flag is 0x0020 in the "Characteristics" field in the IMAGE_FILE_HEADER structure. In OPTLINK-generated executables, one can enable this flag manually by changing byte 0x76 from 0x8E to 0xAE in the executable file. The result - the program can now allocate 3319 megabytes on my machine, thus practically doubling its address space. (Why is it still not anywhere near the theoretical limit?) I've patched my copy of the linker until the official linker is updated. If anyone wants to use more than 2 (or 1.6?) GB in their DMD/Windows programs, change the byte at 0x3CF0D in link.exe from 0x8F to 0xAF.Awesome simple hack; thanks!
Apr 15 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2837
Apr 15 2009
On 15.04.2009 11:28, Vladimir Panteleev wrote:I've patched the executable and enabled the IMAGE_FILE_LARGE_ADDRESS_AWARE flag. This flag is 0x0020 in the "Characteristics" field in the IMAGE_FILE_HEADER structure. In OPTLINK-generated executables, one can enable this flag manually by changing byte 0x76 from 0x8E to 0xAE in the executable file.And for those with msvc installed, editbin.exe supports setting this flag.
Apr 15 2009