I am trying to use a quad-core machine, parallelizing an expensive operation that runs on a list of about 1000 items.
I am using the R parallel :: mclapply function currently:
res = rbind.fill(parallel::mclapply(lst, fun, mc.cores=3, mc.preschedule=T))
What works. The problem is that any additional subprocess that is spawned must allocate a large chunk of memory:

Ideally, I would like each core to access shared memory from the parent R process, so that by increasing the number of cores used in mclapply, I don't use RAM limits to the main ones.
I do not currently understand how to debug this problem. All the large data structures accessed by each process are global (currently). Is this somehow a problem?
I increased the maximum memory setting for the OS to 20 GB (available RAM):
$ cat /etc/sysctl.conf kern.sysv.shmmax=21474836480 kern.sysv.shmall=5242880 kern.sysv.shmmin=1 kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.maxprocperuid=512 kern.maxproc=2048
I thought this would fix, but the problem is still happening.
Any other ideas?
Clayton stanley
source share