Large longitudinal models run in brms crashing on one Mac but not another

I am running a series of gaussian mixed-effects regressions and k-fold cross validations on large messy health datasets using brms and loo; essentially the same model but with different outcomes. They take a long, long time to run and I have three laptops so I am running them on all three at once. I have specified fourteen (of a possible 16) cores for these models just to speed things up.

However I am ecountering a problem on one of the laptops, an Apple M1 Macbook Pro with 16GB RAM running Sonoma iOS 14.1.2, which gets through about half of the 10 folds in the cross validation then crashes (see screenshot below)

The perplexing thing is that the same sorts of models run just fine on my other Mac, an M1 24 GB on Sonoma 14.1.2 iOS but an Air. They take a long time but they don’t crash.

I followed some of the suggestions when other users have had similar issues like updating brms, rstan, and stanheaders, but am still encountering the problem. It doesn’t help that the advice in the answers to those posts (e.g. updating Rtools) pertain to windows not Mac.

Has anyone encountered similar issues and solved them, or can offer advice on where to start troubleshooting the problem with this Mac?

First thing I would check is if the crash is caused by having too little memory, since it works with 24Gb but not 16Gb.

Thank you @Ax3man but I can’t see how it could be that since they also run (very slowly) without crashing on my 16GB hp laptop

Just in case others run into the same problem, what worked for me was

1. Update Xcode

I think this was the most important step. Doing the incredibly intensive k-fold cross-validation simply didn’t work until I did this.

2. Juggle the number of cores and manually increasing the permitted size of the object that you store

This was important for running the models themselves, which required quite a bit of storage memory.

# 16 cores on my 16GB Macbook M1, so leave some for other applications to run. I used between 8 and 12.
options(mc.cores = 12)

# increase globals so we can save large data files. Formula is 'required megaytes * 1024^2'. So if the objects you will be saving are around 8 GB you want 8000MB, so formula is 8000 * 1024^2 = 8388608000. Enter this into the 'future.globals.maxSize=" argument of options
options(future.globals.maxSize= 8388608000)

I think the Xcode update was the most important step.