Cache Cleaner
A 'free the VRAM' button you can drop inside a workflow
- anything
- image_pass
- model_pass
- anything
- image_pass
- model_pass
- status
You know the feeling: you've run a dozen generations, or one long video job, and the next run is sluggish or outright OOMs - ComfyUI is still holding models and cached tensors in VRAM and RAM. Normally you click the menu buttons or restart. Cache Cleaner is the node that does that for you, automatically, at a fixed point in your graph. The name is slightly grand for what it is, but it earns its place in unattended workflows.
How it actually works
Peek under the hood and the "cache cleaner" turns out to be an HTTP call. When the node executes, it grabs ComfyUI's own server address from PromptServer.instance, swaps any 0.0.0.0 for 127.0.0.1, and POSTs to /api/free with {"unload_models": true, "free_memory": true}. That's the same endpoint ComfyUI's frontend hits when you choose "unload models" / "free memory" - so the heavy lifting is done by ComfyUI itself; this node is just an automated click, embedded in the graph.
The clever bit is the pass-through design. All three data inputs come back unchanged, which means you can wire the node inline - run your image or model through it at the exact spot where you want memory freed, and the clean happens right then. One early version tripped over an asyncio event-loop bug; the current code just uses a plain synchronous requests.post with a 10-second timeout, which sidesteps that whole class of problem.
The inputs that matter
Only a couple are worth touching:
- clean_cache (boolean, default true) - the on/off switch. Set it false and the node skips the API call entirely and reports "Cache cleaning skipped." Useful if you keep the node in the graph for the pass-through but don't always want to nuke memory.
- image_pass (IMAGE) and model_pass (MODEL) - pure pass-throughs, there so you can route a render or a checkpoint through the node without breaking your flow.
- anything (any type) - a general-purpose pass-through for whatever else you want to carry.
The only output that does anything is status (STRING): "Cache cleaned successfully" on a 200, or "Error: API returned status code {code}" / "Error: Failed to call API - {error}" when things go wrong. One small trap: the actual string is prefixed with Status: and appends the server address, so if you're string-matching it in another node, match the substring, not the exact phrase from the README.
Install
It's in ComfyUI Manager - search "comfyui-cache-cleaner" or "Cache Cleaner" and hit install. Or by hand:
cd ComfyUI/custom_nodes/
git clone https://github.com/AIToldMeTo/comfyui-cache-cleaner
Then restart ComfyUI and look under utils/system. Good news for a change: there are no dependencies beyond requests (which ComfyUI already ships), no model downloads, no pip install step. It appears in the Comfy registry, so Manager can also update it cleanly.
Gotchas
Where people get burned:
- Position matters. It frees memory while the graph is running. Drop it early and every later node that needs a model will just reload it - slower, not faster. The right spot is after your final Save Image, or between two distinct phases (say, before a second pass or a batch).
- It's synchronous. The HTTP call blocks execution for up to 10 seconds. That's fine mid-batch, but don't chain a dozen of them.
- It assumes a reachable local server. The call goes to ComfyUI's own port, so behind a reverse proxy or a tunnel that hides the real port, you'll see "Error: Failed to call API" and it does nothing.
Honest verdict: if you only ever click through one generation at a time, this node is redundant - the menu buttons already exist. Reach for it when you're running batches overnight or driving ComfyUI from its API, where nobody's around to click. The reddit crowd that fights RAM creeping up after long sessions has been seen wiring exactly this into a tiny cleanup workflow to reset everything between jobs. If that's you, Cache Cleaner is the right tool.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| clean_cache | BOOLEAN | true | — |
| anythingopt | * | — | |
| image_passopt | IMAGE | — | |
| model_passopt | MODEL | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| anything | * | — |
| image_pass | IMAGE | — |
| model_pass | MODEL | — |
| status | STRING | — |