mcmapply() 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
)

Arguments

heapMB

numeric; R heap in use in this process, MB (sum(gc()[, 2])).

availMB

numeric or NULL; memory available on the host, MB. Unknown (NULL, empty, non-finite) means one fork.

nPars

integer; number of parameter sets to evaluate.

detCores

integer; parallel::detectCores().

activeThreads

integer; busy threads already running on the host.

mcCores

integer or NULL; getOption("mc.cores"), an explicit cap.

Value

integer, at least 1.

Details

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.