---
title: "LM Studio — Idle TTL and Auto-Evict"
aliases: [lmstudio-ttl, lmstudio-auto-evict, idle-ttl]
tags: [lmstudio, memory-management, jit-loading, ttl, api]
sources: [raw/Idle TTL and Auto-Evict.md]
created: 2026-04-30
updated: 2026-04-30
---

# LM Studio — Idle TTL and Auto-Evict

Memory management features for LM Studio's JIT-loaded models. Prevents idle models from occupying VRAM and enables seamless model switching from external apps.

## Background

| Feature | Default | Purpose |
|---------|---------|---------|
| **JIT Loading** | enabled | Loads model on first API request — no manual preload needed |
| **Idle TTL** | 60 min | Unloads a model after it has been idle for N seconds/minutes |
| **Auto-Evict** | enabled | Unloads previous JIT model before loading a new one |

## Idle TTL

**Problem:** JIT-loaded models stay in VRAM even when idle (e.g. after you stop using Cline, Zed, or Continue.dev).

**Solution:** TTL starts a countdown when the model goes idle. The timer resets on every new request. When it expires, the model unloads automatically.

### Setting TTL

**App-wide default** — configure in Developer tab → Server Settings.

**Per-request (API)** — pass `ttl` in seconds in the request body:

```bash
curl http://localhost:1234/api/v0/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-r1-distill-qwen-7b",
    "ttl": 300,
    "messages": [...]
  }'
```

Works on both the OpenAI-compat (`/v1/`) and LM Studio REST (`/api/v0/`) endpoints.

**`lms` CLI** — set TTL at load time:

```bash
lms load <model> --ttl 3600   # 1 hour
```

Models loaded with `lms load` have **no TTL by default** (persist until manual unload).

**Server tab** — TTL field visible when loading a model through the GUI.

## Auto-Evict

Controls how many JIT-loaded models can coexist in memory.

| State | Behaviour |
|-------|-----------|
| **ON** (default) | At most 1 JIT model in memory at a time; old model evicted before new one loads |
| **OFF** | Models accumulate in memory; only unloaded by TTL expiry or manual action |

- Non-JIT (manually loaded) models are **never** affected by Auto-Evict.
- Toggle in: Developer tab → Server Settings.

## TTL + Auto-Evict Together

- **Auto-Evict** handles immediate switching — keeps 1 active model.
- **TTL** handles the "forgot to switch" case — cleans up if you just stop using an app.
- Both can be active simultaneously for full memory hygiene.

## Key Takeaways

- Set `"ttl": 300` in any API request to cap a model's idle lifetime to 5 minutes.
- `lms load <model> --ttl 3600` is the CLI equivalent for persistent sessions.
- Auto-Evict (default ON) ensures only 1 JIT model lives in VRAM at a time — great for low-VRAM machines.
- `lms load` bypasses TTL defaults; always pass `--ttl` explicitly if you want auto-cleanup.
- These features are irrelevant for models loaded via the GUI Models tab (non-JIT path).

## Related

- [[wiki/claude-code/lmstudio-anthropic-compat|LM Studio Anthropic Compat]] — redirect Claude Code to local LM Studio
- [[wiki/claude-code/lmstudio-chat-completions|LM Studio Chat Completions]] — full parameter reference incl. `top_k`, `repeat_penalty`
- [[wiki/claude-code/lmstudio-embeddings|LM Studio Embeddings]] — local RAG with FAISS/Chroma

## Sources

- [LM Studio Docs — Idle TTL and Auto-Evict](https://lmstudio.ai/docs/developer/core/ttl-and-auto-evict)
