macOS Sonoma m1 | setrlimit for RLIMIT_RSS fails with error EINVAL

Hi,

I am running the following code on macOS Sonoma m1.

rlimit rlp;
rlp.rlim_cur = 418299658239;
rlp.rlim_max = rlp.rlim_cur  * 2;
int ret = setrlimit(RLIMIT_RSS, &rlp);

setrlimit fails with error 22 (EINVAL) when rlp.rlim_cur <= 418299658239.

I didn't see any documentation for this issue. Is it a known limitation? Is there a workaround or another API to gain the same functionality, that is limiting the process memory?

I saw this failure also on macOS Ventura m1 if rlp.rlim_cur < 418299674624.

Thx, Moshe.

macOS Sonoma m1 | setrlimit for RLIMIT_RSS fails with error EINVAL
 
 
Q