Setting shared memory in Catalina

I have written C software that makes extensive use of shared memory (200MB using shmget, etc.), which compiled and ran on Mojave and Linux. Using this shared memory required /etc/sysctl.conf to increase the buffer sizes during OSX boot. It appears that Catalina no longer uses my /etc/sysctl.conf file, whether SIP is enabled or disabled. Now the software compiles but fails to run, because the default shared memory size (4MB) is too small on Catalina. How do I specify the shared memory parameters to increase above the default in Catalina?

Code Block
kern.sysv.shmmax=268435456
kern.sysv.shmmin=1
#kern.sysv.shmmni=128
kern.sysv.shmseg=32
kern.sysv.shmall=65536

After further digging, the solution to this problem is to place a plist file into /Library/LaunchDaemons/ which runs and sets the shared memory parameters on boot. On Catalina this has to be preceded by disabling SIP, and remounting the / file system as writable, before installing the plist file.

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>Label</key>
 <string>shmemsetup</string>
 <key>UserName</key>
 <string>root</string>
 <key>GroupName</key>
 <string>wheel</string>
 <key>ProgramArguments</key>
 <array>
 <string>/usr/sbin/sysctl</string>
 <string>-w</string>
 <string>kern.sysv.shmmax=268435456</string>
 <string>kern.sysv.shmmni=128</string>
 <string>kern.sysv.shmseg=32</string>
 <string>kern.sysv.shmall=65536</string>
  </array>
 <key>KeepAlive</key>
 <false/>
 <key>RunAtLoad</key>
 <true/>
</dict>
</plist>


Moreover, I am not sure when OSX stopped using the sysctl.conf file, but digging around my Mojave disk I found a plist file with the these same parameters; so the sysctl.conf must have been from a previous upgrade, and probably not even used under Mojave.
I'm using Big Sur, and my sysctl.conf changes aren't working either (although I'm using it for different reasons -- disabling IPv6 privacy addresses). However, I remember it always used to work in both Mojave and Catalina. Maybe a recent update turned off support for sysctl.conf in all of these versions of macOS?

Apple is killing the macOS platform; slow painful death ☹️ It should not be this complicated to change simple OS parameters - I want to turn off Time Machine throttling (debug.lowpri_throttle_enabled=0) and swap (launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist).. I feel I shouldn't have to reboot into Recovery mode, disable SIP, reboot into Recovery mode again, mount encrypted OS drive, create plist file and set parameter and disable swap, enable SIP, reboot yet again - 30 minutes later on a good day? If Catalina wasn't bad enough - Big Sur sure is - after Apple drops support for Catalina, I am outta here unless some major simplicity improvements magically happens in the next few releases.. Like downloadable OS update dmg files - yet another very sad topic...Usability is gone and it is not for real developers any more - the platform is dead to me

If you need a lot of shared memory, use a memory-mapped file instead. Create a file, then call mmap on it with permissions PROT_READ | PROT_WRITE and attributes MAP_FILE | MAP_SHARED.

If you don't want the file to hang around in the filesystem, you can delete (unlink) it as soon as your process(es) have mapped it; the memory remains valid until the memory map is removed or all the processes exit.

Setting shared memory in Catalina
 
 
Q