skip to content

With LM Studio's JIT loading on, when does a model the server loaded on demand get unloaded, and how do you change that?

level: middleimportance: should knowfreq 9%

answer

  1. first request does the loading
  2. an idle timer, not a lifetime
  3. an hour unless told otherwise
  4. a request field counted in seconds
  5. only the loading request sets it

basics

~20 s

A JIT-loaded model unloads after sitting idle for its TTL, 60 minutes by default. Change the app-wide default for JIT loads in the server settings, or send a ttl field, in seconds, with the request that loads it.

solid answer

~50 s

With **Just in Time Model Loading** on, the default, the first request that names an unloaded model loads it, and that model gets an **idle TTL** of 60 minutes by default. The timer resets on every request, a model doing work counts as busy, and when the TTL runs out the server unloads it. You change it in two places: an app-default TTL that applies to every JIT-loaded model, or a `ttl` field in the request payload, in seconds, which works on the OpenAI-compatible routes and the REST API and applies when that request is the one that JIT-loads the model. Models you load yourself are not JIT-loaded: ones loaded with the CLI keep no TTL unless given one. Separately, **Auto-Evict** can unload a JIT model sooner, when a request for a different model arrives.

code

bash · 7 lines
bash
curl http://localhost:1234/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model",
    "ttl": 300,
    "messages": [{"role": "user", "content": "Summarise this diff."}]
  }'

go deeper

for a junior

Recall that JIT loading is on by default and that a model it loads is unloaded after 60 idle minutes.

for a middle

Explain that the timer is idle-based and resets per request, the ttl field in seconds, the app default, and why hand-loaded models keep no TTL.

for a senior

Diagnose an unexpected unload by telling the TTL apart from Auto-Evict, and choose between a request ttl and a hand-loaded model for clients with long gaps between calls.

for a principal

Treat the TTL as the trade between idle memory and first-call latency on a shared machine, and decide which clients get JIT convenience and which get pinned models.

## What JIT loading does **Just in Time (JIT) model loading** is the LM Studio server setting that lets a client name any downloaded model without loading it first. It is **enabled by default**. When a request arrives for a model that is not in memory, the server loads it, then answers; the client sees one slow response and nothing else. This is what lets an editor plugin or a script switch models just by changing the `model` field. The cost of that convenience is memory. A model loaded on demand would stay resident long after the client stopped using it, holding gigabytes of RAM or VRAM. LM Studio's answer is the **idle TTL** (time-to-live). ## How the idle TTL counts - Every JIT-loaded model gets a TTL; the default is **60 minutes**. - The timer is an **idle** timer: it resets every time the model receives a request, so a model in active use does not disappear. - A model counts as idle only when it is not doing any work, so a long generation does not count against it. - When the TTL expires the server unloads the model; the next request for it loads it again, paying the load time once more. ## Three ways the TTL gets set | How the model was loaded | TTL it gets | How you change it | |---|---|---| | JIT, by a request with no `ttl` | the app default, 60 minutes unless changed | the app-default idle TTL in the server settings | | JIT, by a request carrying `ttl` | that value, in seconds | the `ttl` field in the request payload | | Loaded by hand with the CLI | none: stays until unloaded | give it a TTL when loading it | The server tab also lets you set a TTL when you load a model there by hand. Server Settings carry an **Auto Unload Unused JIT Models** switch, described as unloading JIT-loaded models once they are no longer in use, next to **Just in Time Model Loading** itself. ## The `ttl` field The `ttl` field sits beside `model` and `messages` in the JSON body and is counted in **seconds**: `300` means five minutes. LM Studio documents it for both the OpenAI-compatible routes and its own REST API. Its effect is tied to the load: the docs describe it setting the TTL for the model *if this request JIT-loads it*. A request that reaches a model already in memory, loaded earlier by another request or by hand, is not the request that loaded it, so do not rely on it to reset that model's lifetime. ## Choosing a value 1. **Interactive tools on a laptop** — the default hour suits an editor session; shorten it if the machine also runs other memory-hungry work. 2. **A memory-tight machine shared with other programs** — send a short `ttl` (a few minutes) from clients that call rarely, so their model does not sit in VRAM between uses. 3. **A model every request needs** — do not lean on JIT at all; load it by hand so no idle timer applies. 4. **A latency-sensitive client that calls every few hours** — a TTL shorter than the gap means every call pays a full load; either lengthen the TTL or keep the model loaded by hand. ## How it interacts with Auto-Evict The TTL is a **time** rule. **Auto-Evict**, also on by default, is a **count** rule: it keeps at most one JIT-loaded model, unloading the previous one before a different one is JIT-loaded. A JIT model can therefore vanish well before its hour is up, simply because a client asked for another model. When diagnosing an unexpected unload, check which rule fired before touching the TTL. ## Where the TTL is not the answer - **A client that calls every few hours** reloads on each call with the default hour; that is the TTL doing its job, not a fault. - **Memory pressure from other programs** does not shorten it: the documented TTL is purely time-based, so an idle model holds its memory until the timer runs out. - **Models you loaded yourself** ignore the app default, which applies to JIT loads only; changing it does not touch them. - **A model that vanished after a model switch** was removed by Auto-Evict, not by the timer. The idle TTL and Auto-Evict arrived together in LM Studio 0.3.9.

  • One request streams a generation for 70 minutes. Can the 60-minute TTL unload the model mid-stream?
    No. LM Studio counts a model as idle only while it is not doing any work, and the timer resets on every request. The TTL starts counting once the generation finishes and no further request arrives.
  • A client sends ttl: 300, yet the model is still loaded half an hour later. Why?
    The field applies when that request is the one that JIT-loads the model. If the model was already in memory, loaded by an earlier request with the default hour or loaded by hand, this request did not load it, so its ttl did not set that model's lifetime.

A JIT-loaded model is like a hotel room held for a guest who keeps coming back: every visit restarts the hold, and only after a full hour with no visits does the hotel release the room.

  • A JIT-loaded model stays in memory until someone unloads it by hand.
  • The idle TTL counts from load time, whether or not requests keep arriving.
  • The ttl field in an LM Studio request is counted in minutes.
  • Models loaded with the CLI also expire after 60 idle minutes by default.
  • Raising the TTL stops a JIT model from ever being unloaded early.