Ollama keep_alive: how long models stay loaded and how much VRAM they hold

By LLM Hardware team · Methodology ·

LLM Hardware team

Short answer

Ollama keeps a model in memory for 5 minutes after its last request, then unloads it. Ollama's FAQ (read 22 November 2026) gives three ways to change that. Send keep_alive in an API request, set OLLAMA_KEEP_ALIVE for the whole server, or run ollama stop <model> to unload one model right now. A keep_alive of 0 unloads the model after the response, and any negative number such as -1 keeps it loaded.

While a model stays loaded it holds its VRAM, so keep_alive is also a memory setting. The sections below cover each value, how to read ollama ps, how many models Ollama loads at once, and a VRAM budget for loading two models together on the GPUs in the site's hardware catalog. For the full command list, see the Ollama cheat sheet.

What the keep_alive values mean

The FAQ says keep_alive works on both /api/generate and /api/chat, and accepts four kinds of value.

keep_alive valueExampleResult, per the FAQ
Duration string"10m", "24h"The model stays in memory for that long after the last request
Number of seconds3600The model stays in memory for that many seconds
Any negative number-1, "-1m"The model stays loaded in memory
Zero0The model unloads immediately after generating a response

The FAQ gives these two examples with the llama3.2 tag. The first loads the model and leaves it in memory. The second unloads it and frees the memory.

curl http://localhost:11434/api/generate -d '{"model": "llama3.2", "keep_alive": -1}'
curl http://localhost:11434/api/generate -d '{"model": "llama3.2", "keep_alive": 0}'

From a terminal, ollama stop llama3.2 unloads the model without an API call. The FAQ describes that command as the way to unload a model from memory immediately.

Set OLLAMA_KEEP_ALIVE for every model

OLLAMA_KEEP_ALIVE is an environment variable you set when the server starts. The FAQ says it takes the same kinds of value as the API parameter and changes the time all models stay loaded. It also says the keep_alive parameter on /api/generate and /api/chat overrides OLLAMA_KEEP_ALIVE. So the variable is the default for the server, and a single request can still ask for something different.

Where you set the variable depends on how Ollama runs. The FAQ's configuration section gives these steps:

The 24h value in those lines is only an example of the duration format. Pick the time that matches how long you leave a model idle.

Preload a model before the first request

The FAQ documents preloading as a way to get faster response times. Over the API, send an empty request to /api/generate or /api/chat, such as curl http://localhost:11434/api/generate -d '{"model": "mistral"}'. From the CLI, run ollama run llama3.2 "". The FAQ's example for preloading a model and leaving it in memory is the same request with keep_alive set to -1.

Check what is loaded with ollama ps

ollama ps lists the models currently in memory. The FAQ's example output has these columns: NAME, ID, SIZE, PROCESSOR and UNTIL. Ollama's context length page shows a version with a CONTEXT column between PROCESSOR and UNTIL, so a current install can show both.

Running ollama ps right after a request and again a few minutes later is the quickest way to confirm that your keep_alive or OLLAMA_KEEP_ALIVE value took effect.

How many models Ollama loads at once

Ollama can hold several models in memory together, but only when they fit. The FAQ says that with enough available memory (VRAM for GPU inference, system memory for CPU inference) multiple models can be loaded at the same time. On a GPU, a new model must be able to fit completely in VRAM to be loaded alongside others. If it does not fit, new requests queue until the model can load, and idle models are unloaded to make room.

The FAQ lists three server settings for this.

SettingWhat it limitsDefault, per the FAQ
OLLAMA_MAX_LOADED_MODELSModels loaded at once, if they fit in memory3 times the number of GPUs, or 3 for CPU inference
OLLAMA_NUM_PARALLELParallel requests each model handles1 on most backends. MLX on Metal picks a conservative value from available memory
OLLAMA_MAX_QUEUERequests queued while Ollama is busy512

When the queue is full, Ollama responds with a 503 overloaded error, and the FAQ's example for raising the limit is OLLAMA_MAX_QUEUE=1024 ollama serve. The FAQ also notes that Windows with Radeon GPUs defaults to a maximum of one loaded model because of how ROCm reports VRAM, so check that note if you run AMD on Windows.

Parallel requests cost memory. The FAQ says parallel processing multiplies the context size by the number of parallel requests, and its example is a 2K context with 4 parallel requests becoming an 8K context with extra memory allocated.

VRAM budget for two loaded models

Keeping a second model resident means its weights sit in VRAM next to the first. The table uses the site formula from the methodology page: GB = parameters in billions x bytes per parameter x 1.2 + 2. The 2 GB reserve for the OS and engine is counted once, not once per model, so a pair is the weights times 0.6 at 4-bit (0.5 bytes per parameter times 1.2) plus 2 GB.

Models loaded (4-bit)ArithmeticEstimate12 GB (RTX 4070)16 GB (RTX 4080, RTX 4060 Ti)24 GB (RTX 3090, RTX 4090)32 GB (RTX 5090)
14B alone14 x 0.6 + 210.4 GBYesYesYesYes
8B + 8B16 x 0.6 + 211.6 GBYesYesYesYes
8B + 14B22 x 0.6 + 215.2 GBNoYesYesYes
14B + 14B28 x 0.6 + 218.8 GBNoNoYesYes
8B + 32B40 x 0.6 + 226.0 GBNoNoNoYes

The card names come from the site's catalog, whose VRAM figures are 12 GB for the NVIDIA GeForce RTX 4070, 16 GB for the NVIDIA RTX 4080 and NVIDIA RTX 4060 Ti, 24 GB for the NVIDIA GeForce RTX 3090 and NVIDIA GeForce RTX 4090, and 32 GB for the NVIDIA GeForce RTX 5090. "Yes" means the estimate is below the card's VRAM. It does not mean there is room to spare. The 8B + 8B pair leaves 0.4 GB on a 12 GB card.

Why the estimate understates a long context

The formula's 1.2 factor assumes a short context of about 4K to 8K tokens, which the methodology page states. Ollama's context length page says its default context depends on VRAM: 4k tokens under 24 GiB, 32k tokens from 24 to 48 GiB, and 256k tokens at 48 GiB or more. Cards at 24 GiB and above can therefore get a default context far longer than the formula assumes, and the CONTEXT column in ollama ps shows the value you got.

You can size the gap for one model. Qwen3 8B's configuration on Hugging Face lists 36 layers, 8 key-value heads and a head dimension of 128. At 16-bit, that is 36 x 8 x 128 x 2 x 2 bytes, or 147,456 bytes per token, which is 4.83 GB for a 32,768 token context. Ollama's FAQ gives f16 as the default KV cache type, so that is the starting point unless you change OLLAMA_KV_CACHE_TYPE. The KV cache quantization guide covers that setting, and the VRAM guide covers the weights side. Treat the table as a lower bound for a pair, and read SIZE in ollama ps after both models load.

Which setting to change

FAQ

How long does Ollama keep a model loaded by default?

Five minutes. Ollama's FAQ says models are kept in memory for 5 minutes before being unloaded, which makes repeated requests quicker.

How do I unload an Ollama model right now?

Run ollama stop followed by the model name, for example ollama stop llama3.2. Over the API, send a request for that model with keep_alive set to 0.

How do I keep an Ollama model loaded forever?

Set keep_alive to a negative number such as -1 in an API request, or set OLLAMA_KEEP_ALIVE to a negative value when the server starts. The FAQ says any negative number keeps the model loaded in memory.

Does the API keep_alive override OLLAMA_KEEP_ALIVE?

Yes. The FAQ says the keep_alive parameter on /api/generate and /api/chat overrides the OLLAMA_KEEP_ALIVE setting.

How many models can Ollama load at the same time?

The default for OLLAMA_MAX_LOADED_MODELS is 3 times the number of GPUs, or 3 for CPU inference, as long as the models fit in available memory. On a GPU, each additional model has to fit completely in VRAM.

How do I see which models are loaded and when they unload?

Run ollama ps. The UNTIL column shows when each model will unload, and PROCESSOR shows whether it is on the GPU, the CPU or split between them.

Sources

#URLClaim it supportsDate checked (PT)
1 https://docs.ollama.com/faq 5 minute default, ollama stop, keep_alive values, OLLAMA_KEEP_ALIVE and override rule, preload commands, OLLAMA_MAX_QUEUE and 503, concurrency rules, OLLAMA_MAX_LOADED_MODELS, OLLAMA_NUM_PARALLEL and OLLAMA_MAX_QUEUE defaults, parallel context example, Radeon on Windows note, ollama ps columns and PROCESSOR meanings, OLLAMA_KV_CACHE_TYPE default f16, environment variable steps per OS 2026-11-22
2 https://docs.ollama.com/context-length Default context by VRAM (4k, 32k, 256k), ollama ps output with a CONTEXT column 2026-11-22
3 https://docs.ollama.com/api/generate keep_alive parameter on /api/generate 2026-11-22
4 https://docs.ollama.com/cli ollama stop and ollama ps commands 2026-11-22
5 https://huggingface.co/Qwen/Qwen3-8B Qwen3 8B configuration: 36 layers, 8 key-value heads, head dimension 128 2026-11-22
6 https://llmhardware.io/methodology Site formula GB = params x bytes per param x 1.2 + 2, 1.2 factor assumes 4K to 8K context, 2 GB OS and engine reserve 2026-11-22
7 https://llmhardware.io/hardware Catalog GPUs and VRAM: RTX 4070 12 GB, RTX 4080 16 GB, RTX 4060 Ti 16 GB, RTX 3090 24 GB, RTX 4090 24 GB, RTX 5090 32 GB 2026-11-22