[Issue 21089] New: With vm.overcommit_memory=0, DMD can't link if it uses more than half the total (ram+swap) memory in the system.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jul 29 13:30:35 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21089
Issue ID: 21089
Summary: With vm.overcommit_memory=0, DMD can't link if it uses
more than half the total (ram+swap) memory in the
system.
Product: D
Version: D2
Hardware: x86
OS: Linux
Status: NEW
Severity: minor
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: default_357-line at yahoo.de
This is because DMD fork()s to start the linker. Fork temporarily
overcommit-allocates, and the allocation is refused by the system if
`vm.overcommit_memory=0` and the forked DMD would push the total used address
space over the total of memory + swap.
This is a known issue, see the vfork() doc:
* On systems where memory is constrained, vfork() avoids the need to
temporarily commit memory (see the description of
/proc/sys/vm/overcommit_memory in proc(5)) in order to execute a
new program. (This can be especially beneficial where a large
parent process wishes to execute a small helper program in a child
process.) By contrast, using fork(2) in this scenario requires
either committing an amount of memory equal to the size of the
parent process (if strict overcommitting is in force) or
overcommitting memory with the risk that a process is terminated
by the out-of-memory (OOM) killer.
But vfork() is itself deprecated.
The fork call should be replaced with posix_spawn(), which does not share
caller process memory.
--
More information about the Digitalmars-d-bugs
mailing list