简体   繁体   中英

"No space left on drive" when trying to allocate more shared memory

MacOS. 16GB RAM

I'm running code (which other users are running on similar hardware) allocating shared memory. It gets halfway through, then dies with the message:

Error allocating shared memory:: No space left on device

I've checked:

sysctl -A | grep shm               
kern.sysv.shmall: 1024
kern.sysv.shmmax: 4194304
kern.sysv.shmmin: 1
kern.sysv.shmmni: 32
kern.sysv.shmseg: 128
security.mac.posixshm_enforce: 1
security.mac.sysvshm_enforce: 1

I tried to increase shmall but kept getting:

sysctl: unknown oid 'kern.sysv.shmall:'

Anyone know how to fix this?

This looks like a duplicate of https://unix.stackexchange.com/questions/689295/values-from-sysctl-a-dont-match-etc-sysctl-conf-even-after-restart/710645 .

I can copy/paste my answer here, but not sure if that's double dipping haha. The tl;dr is you'll need to create a LaunchDaemon after disabling SIP :

<?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">
<!-- DISABLE SIP TO USE: macOS Recovery > Utilities > Terminal > `csrutil disable` > Reboot -->
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.startup.sysctl</string>
        <key>LaunchOnlyOnce</key>
        <true/>
        <key>StandardErrorPath</key>
            <string>/private/tmp/sysctl.err</string>
        <key>StandardOutPath</key>
            <string>/private/tmp/sysctl.out</string>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/sbin/sysctl</string>
            <string>-w</string>
            <string>kern.sysv.shmmax=4194304</string>
            <string>kern.sysv.shmmin=1</string>
            <string>kern.sysv.shmmni=32</string>
            <string>kern.sysv.shmseg=128</string>
            <string>kern.sysv.shmall=1024</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    </dict>
</plist>

Then load with sudo launchctl bootstrap system /Library/LaunchDaemons/com.startup.sysctl.plist

Output looks like this:

λ tail -f /tmp/sysctl.out
kern.sysv.shmmax: 16777216 -> 4194304
kern.sysv.shmmin: 1 -> 1
kern.sysv.shmmni: 4096
kern.sysv.shmseg: 512 -> 128
kern.sysv.shmall: 4096 -> 1024

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM