Notes from the work

One email when a tutorial or migration write-up goes live. Nothing else, and an unsubscribe link in every email.

LeanZero

Two people in Romania doing Atlassian migrations, Forge apps and practical AI work for teams that would rather talk to the person doing the job. Most of what we learn ends up on this site.

Services

  • Atlassian migrations
  • Atlassian FastShift
  • Atlassian maintenance
  • Forge app development
  • AI development consultation

Topics

  • Jira
  • Jira Service Management
  • Confluence
  • Bitbucket
  • Atlassian Forge
  • Cloud Migration
  • Local AI
  • AI Coding
  • Certifications
  • Atlassian Team
  • All topics

Company

  • Blog
  • Tutorials
  • Contact

Community

  • Join Discord
  • Support this site

© 2026 LeanZero. All rights reserved.

Privacy policyTerms of service24/7 SupportTrust centerSecurityDPALegal notice
  1. Home
  2. Portfolio
  3. Elzi
  4. Features
  5. Memory Lock
Elzi feature guide

Memory lock

Keep memory for your local model while other apps compete for it.

Other apps can take memory away from a local model while it works, and a long chat then slows down or gets refused. The memory lock, added in Elzi 4.1.3, keeps a measured amount of memory for the engine so that doesn't happen. It is off until you turn it on. In our test on a MacBook Pro, the time to the first token with the lock on matched a run with no other app competing, while the unlocked engine fell up to 27 % behind.

How to use it

  1. Open the LeanZero MLX view and go to the Memory tab.
  2. Choose "Test and lock from the Engine tab". A Memory lock panel appears.
  3. Run the context test. It measures how much memory this Mac can keep for the mounted model right now and how many tokens of context that buys.
  4. Press Lock to keep it, or Release to give it back to macOS.

"Lock when the model mounts" takes the lock every time the model loads, sized by the test or by a token count you set. On critical memory pressure the lock gives memory back by default; "Hold the lock" keeps it instead. The panel shows since when it holds, what limited the test, and how much the engine really holds if macOS didn't let it wire all of it.

How it works

The engine wires a reserve of memory pages that other apps can't take. Right before a step needs room, it releases a chunk of that reserve, and it fills the reserve again afterwards. The lock is a minimum, not a cap: context beyond it still runs, on whatever memory is free. Filling the reserve stops at the first macOS memory-pressure warning or when swap starts to grow.

What we measured

RunTurn 2Turn 3Turn 4Turn 5
No lock, quiet Mac51.4 s94.1 s87.4 s103.6 s
No lock, competing app50.7 s84.7 s105.8 s131.2 s
Lock on, quiet Mac49.3 s66.5 s86.9 s101.7 s
Lock on, competing app48.5 s64.4 s87.8 s103.9 s
Qwen3.5-9B (4-bit) on a MacBook Pro (M4 Max, 128 GB), 6 November 2026. Five turns grew one chat from 29k to 145k tokens while another process filled memory to the pressure warning plus 6 GiB. Time to first token on turns 2 to 5.

Each setup is compared with itself on a quiet Mac. Without the lock, turns 4 and 5 were 21 % and 27 % slower under competition; with the lock they stayed within 1-2 %, and a second locked run the same day matched again. On turns 2 to 4, decode speed held at 75-89 % of the reference with the lock and fell to 52-60 % without it. In the second run the unlocked engine refused a 144,614-token prompt, while the locked engine served 144,735 tokens.

The app allows about a minute for the context test; our runs finished in under a second. On 6 November 2026 the first test, taken before any prompt, estimated about 30 GB for Qwen3.5-9B's full 262,144-token window. After the first prompt the calibrated figure on the MacBook was 37.2 GB, which is why it pays to test again. We also checked Lock and Release in the released app on the M5 Max Mac Studio.

Limits we know about

  • These are two locked runs with one model on one MacBook. Treat the numbers as a first measurement.
  • Decode can still slow down under heavy competition (about 20 % in the first run), because macOS compression work is not covered.
  • The give-back on critical pressure is proven in tests only. In a live try macOS swapped 12 GiB in 32 seconds without ever reporting critical pressure, so the panel shows swap as well.
  • Prompt-cache entries count inside the lock, so the token figure assumes an empty prompt cache. A test before the first prompt is an estimate; test again after it for the calibrated figure.
  • The two-Mac split engine doesn't have the lock yet.

Related guides

Serving a model on one MacElzi checks the memory, mounts the model and keeps long chats inside what fits.The LeanZero MLX engineThe local model server inside Elzi, built on our fork of Rapid-MLX.Speed: measured numbersDecode, prefill and time to first token from our own runs, with model, Mac and date.

Facts on this page were checked against our own test records on 6 November 2026.

Using Elzi

  • What Elzi is
  • Agent sessions
  • Software build sessions
  • Benchmark runs
  • Nodes and strategies
  • Providers

The MLX engine

  • The LeanZero MLX engine
  • Serving a model on one Mac
  • Distributed serving across two Macs
  • N-gram tables and prompt lookup
  • Speed: measured numbers
  • Memory lock

Media and devices

  • Images
  • Voices
  • LeanZero Link

Elzi

  • All feature guides
  • Download and user manual