Performance Tip: Lock Local Model VRAM/RAM with LimitMEMLOCK=infinity

✍️ OpenClawRadar📅 Published: September 16, 2026🔗 Source
Ad

If your local model fits inside your combined VRAM and RAM, you can keep the model provider's memory resident by adding LimitMEMLOCK=infinity under the [Service] header of the systemd unit for your provider. The kernel then stops paging model weights out to disk, which is where most of the slowdowns come from once a model is loaded.

The unit file

Posted in r/openclaw as a working example for LM Studio (edit the paths and usernames to match your install):

[Unit]
Description=LM Studio Server
RequiresMountsFor=/home

[Service] LimitMEMLOCK=infinity Type=oneshot RemainAfterExit=yes User=******** Environment="HOME=/home/" ExecStartPre=/home//.lmstudio/bin/lms daemon up ExecStartPre=/home//.lmstudio/bin/lms load text-embedding-bge-large-en-v1.5 --yes ExecStartPre=/home//.lmstudio/bin/lms load qwen3.6-35b-a3b-uncensored-hauhaucs-aggressive --yes ExecStart=/home//.lmstudio/bin/lms server start ExecStop=/home//.lmstudio/bin/lms daemon down

[Install] WantedBy=multi-user.target

Ad

What each part does

  • LimitMEMLOCK=infinity — removes the default per-process mlock cap, so the loaded model can be kept out of swap/paging.
  • ExecStartPre with lms daemon up — starts the LM Studio daemon before anything else.
  • lms load <model> --yes — preloads each model at service start. The example loads an embedding model (text-embedding-bge-large-en-v1.5) and a chat model (qwen3.6-35b-a3b-uncensored-hauhaucs-aggressive).
  • lms server start as ExecStart — brings up the OpenAI-compatible server.
  • lms daemon down as ExecStop — cleans up on shutdown.
  • RequiresMountsFor=/home — ensures the home partition holding the model files is mounted before the service starts.
  • Type=oneshot + RemainAfterExit=yes — the unit is treated as active after the start commands finish, which fits a daemon the lms CLI manages separately.

Caveat

The tip explicitly assumes the model fits in VRAM+RAM. If it doesn't, locking memory is the wrong lever — you'll just push the problem elsewhere. Once it fits, the win is avoiding paging-induced stalls on inference.

To apply: drop the block into your unit file, then systemctl daemon-reload and restart the service. Developers running LM Studio headless as a systemd service are the target audience here; the same idea applies to any provider process whose weights you want pinned in memory.

📖 Read the full source: r/openclaw

Ad

👀 See Also