---
title: "Docker and Ollama memory after closing on Mac · MacMelon"
description: "Docker Desktop runs a virtual machine and Ollama keeps models loaded. How to see what each holds, unload models, and cap Docker's memory on a Mac."
url: "https://macmelon.com/guides/docker-and-ollama-memory-after-closing-on-mac"
---

# Docker and Ollama still using memory after you close them

Docker Desktop keeps a virtual machine running, and Ollama keeps a model in memory for minutes after the last request. Closing the window frees neither. Here are the commands that do.

By [Harish Ganapathi](https://macmelon.com/about), Co-founder · Updated November 13, 2026

Two tools surprise Mac developers with memory they did not expect to still be in use. Docker Desktop runs your containers inside a virtual machine that holds the memory you allowed it, whether or not any container is busy. Ollama loads a model into memory when you first use it and keeps it there for a few minutes afterwards so the next request is fast.

Neither is a bug. Both are trade-offs you can adjust. This guide shows what each one holds right now and how to give memory back without losing anything.

## Ollama: see and unload the loaded model

The Ollama menu bar app and its background server stay running when you close the chat window. The server loads a model on the first request and, by default, keeps it in memory for 5 minutes after the last one. A large model can hold many gigabytes in that time.

List models currently loaded, with their size and when they will unload

```
ollama ps
```

An empty list means nothing is loaded. The `UNTIL` column shows when Ollama will unload the model by itself.

Unload a model now (replace the name with one from \`ollama ps\`)

```
ollama stop llama3.2
```

This frees the model's memory immediately. The next request loads it again, which takes a few seconds.

Change how long models stay loaded (run before starting the server)

```
OLLAMA_KEEP_ALIVE=1m ollama serve
```

The default is `5m`. If you start Ollama from the menu bar app instead, set the variable with `launchctl setenv OLLAMA_KEEP_ALIVE 1m` and restart the app.

## Docker Desktop: what the virtual machine holds

Docker Desktop on a Mac runs Linux in a virtual machine, and macOS sees it as one large process. The memory limit you set under Settings > Resources is a ceiling for that machine, and the machine takes what it needs up to the ceiling. Containers you have stopped do not hold memory, but the machine itself stays up while Docker Desktop is open.

Memory and CPU used by each running container

```
docker stats --no-stream
```

If this prints `Cannot connect to the Docker daemon`, Docker Desktop is not running and is holding no memory.

Stop every running container

```
docker stop $(docker ps -q)
```

Disk used by images, containers and volumes, and what is reclaimable

```
docker system df
```

## Give Docker's memory back

Quitting Docker Desktop from its menu bar icon (Quit Docker Desktop) stops the virtual machine and returns its memory. Closing the dashboard window does not. If you start Docker every day but use it for a few hours, quit it when you finish.

If you leave it running, lower the memory limit in Settings > Resources to what your containers need, and consider turning on Resource Saver mode in recent versions, which pauses the machine when no containers are running. Check `docker stats` while your normal stack is up to see how much it uses.

## Docker's disk use is a different problem

Docker Desktop stores its images and volumes in one disk image, `Docker.raw`, in `~/Library/Containers/com.docker.docker/Data/vms/0/data`. It is a sparse file: Finder and `ls` show its maximum size, which can be far larger than what it really uses. Use `du -sh` to see the real figure. It counts toward System Data in Storage settings, which is covered in [why System Data is so large](https://macmelon.com/guides/why-is-mac-system-data-so-large).

Real disk space Docker's disk image uses

```
du -sh ~/Library/Containers/com.docker.docker/Data/vms/0/data
```

## Why the memory does not feel free afterwards

macOS does not hand freed memory straight to another app; it keeps it as cache until something needs it. So the useful check is memory pressure and swap, not the free number. After unloading a model or quitting Docker, run `sysctl vm.swapusage` and watch whether swap stops growing. Swap already written to disk is only read back when needed.

-   [Get memory back from local AI models and Docker Desktop](https://macmelon.com/use-cases/get-memory-back-from-ollama-and-docker)
-   [How to find what is slowing down your Mac](https://macmelon.com/guides/how-to-find-what-is-slowing-down-your-mac)
-   [Swap](https://macmelon.com/glossary/swap-memory)

## When to let an app do it

[Sentinely](https://macmelon.com/apps/sentinely) shows models loaded in Ollama and the memory Docker Desktop holds, offers to unload the models or quit Docker Desktop (which stops its containers), and measures what came back. The check and your first fix are free.

-   [Sentinely](https://macmelon.com/apps/sentinely)

## Questions

Why is Ollama still using memory when I am not using it?

Ollama keeps a model loaded for 5 minutes after the last request by default, so the next one is fast. Run `ollama ps` to see what is loaded and `ollama stop <model>` to unload it now.

How do I unload an Ollama model from memory?

Run `ollama stop` followed by the model name shown by `ollama ps`. The memory is released immediately and the model loads again on the next request.

Does closing the Docker Desktop window free memory?

No. The virtual machine keeps running while Docker Desktop is open. Use Quit Docker Desktop from the menu bar icon to stop it and return its memory.

How do I limit how much memory Docker uses on a Mac?

Open Docker Desktop, go to Settings > Resources and lower the memory limit. Use `docker stats --no-stream` with your usual containers running to see what you actually need.

Why does Docker.raw look so large in Finder?

It is a sparse disk image. Finder shows its maximum size, not what it really occupies. `du -sh` on the folder shows the space it actually uses.

## Related use cases

[### Get memory back from local AI models and Docker Desktop](https://macmelon.com/use-cases/get-memory-back-from-ollama-and-docker)[### Find out why your Mac is slow](https://macmelon.com/use-cases/find-out-why-your-mac-is-slow)[### Stop AI-tool helpers left running after you close your editor](https://macmelon.com/use-cases/stop-leftover-ai-helpers-and-mcp-servers)

## Related terms

[### Memory pressure](https://macmelon.com/glossary/memory-pressure)[### Swap](https://macmelon.com/glossary/swap-memory)[### Memory footprint](https://macmelon.com/glossary/memory-footprint)[### System Data](https://macmelon.com/glossary/system-data)

## Related notes

[### Developer Mac memory after two days: measured](https://macmelon.com/blog/developer-mac-memory-snapshot-november-2026)
