thresholdForks.Rdmcmapply() forks this process. Each child starts as a copy-on-write image
of the parent and diverges as R's garbage collector marks the heap, so the
honest per-child budget is the parent's own R heap, not a fixed 5000 MB: on
2026-09-07 the forks of a ~90 GB parent each reached ~37 GB of private
memory within minutes. There is no floor above one. The previous
max(4L, ...) forced four such children per simulation whatever the host
had left and whatever options(mc.cores) said; three simulations doing that
on one host exhausted 1 TB.
thresholdForks(
heapMB,
availMB,
nPars,
detCores,
activeThreads = 0L,
mcCores = NULL
)numeric; R heap in use in this process, MB (sum(gc()[, 2])).
numeric or NULL; memory available on the host, MB.
Unknown (NULL, empty, non-finite) means one fork.
integer; number of parameter sets to evaluate.
integer; parallel::detectCores().
integer; busy threads already running on the host.
integer or NULL; getOption("mc.cores"), an explicit cap.
integer, at least 1.
Threads already busy on the host reduce the CPU budget only. The previous code subtracted them from the minimum of every budget, which on a shared host went negative and landed back on the floor.