ComfyUI Free Model and Node Cache
A ComfyUI custom node that replicates the function of the -Free model and node cache- toolbar button, usable INLINE in a workflow, so you can force a VRAM/RAM cleanup automatically after every generation instead of clicking a button manually.
Free Model & Node Cache
A ComfyUI custom node that replicates the function of the "Free model and node cache" toolbar button — usable inline in a workflow, so you can force a VRAM/RAM cleanup automatically after every generation instead of clicking a button manually.
The Problem
ComfyUI's UI has a "Free model and node cache" button (top toolbar) that unloads all models from VRAM and system RAM. I found no equivalent node for this function, that you can drop into a workflow graph and that really clears everything, as if the UI button would be pressed (which I often forgot).
Existing cache-clearing nodes (e.g. "Clean VRAM used" / "Clear cache all" from ComfyUI-Easy-Use) operate through ComfyUI's Python-level model management objects from inside the graph. In practice, this is noticeably weaker than the toolbar button: with demanding checkpoints (e.g. large bf16 models), VRAM usage creeps up across consecutive generations even with those nodes in place, eventually hanging the whole ComfyUI process and requiring a hard restart.
The Solution
This node calls ComfyUI's own internal REST endpoint — the same one the toolbar button uses:
POST /api/free
{ "unload_models": true, "free_memory": true }
This goes through the server layer that directly owns the model cache, so it reliably frees VRAM/RAM the way the button does — something the in-graph cache-clearing nodes can't fully replicate.
The node is a wildcard passthrough: its input/output socket accepts any type (IMAGE, LATENT, video frames, etc.) — the same mechanism ComfyUI's built-in Reroute node uses. This lets you insert it anywhere in a chain, for example between a VAE Decode and a Save Image / Save Video node, without breaking the connection.
Node Options
| Input | Type | Default | Description |
|---|---|---|---|
| anything | any | — | Pass-through connection (e.g. from VAE Decode) |
| enabled | boolean | true | Toggle the cleanup on/off without rewiring |
| unload_models | boolean | true | Unload models from VRAM |
| free_memory | boolean | true | Free cached memory |
| Output | Type | Description |
|---|---|---|
| anything | any | Passed through unchanged to the next node |
| status | string | Result message, useful for logging/debugging |
Installation
cd ComfyUI/custom_nodes/
git clone https://github.com/VRAM-Hoarder/ComfyUI-Free_model_and_node_cache.git
No external requirements. Just restart ComfyUI. The node appears under utils/system as "Free Model & Node Cache".
Usage
Place the node between your final generation step and your save node, e.g.:
VAE Decode → Free Model & Node Cache → Save Image
<img width="1692" height="469" alt="grafik" src="https://github.com/user-attachments/assets/8fabda08-8b03-4318-8d89-713f8f96f39c" />
Each time the workflow runs, it will unload the model and free memory right after decoding — before the next run starts. This trades a small model-reload time on the next generation (negligible on fast NVMe storage) for eliminating VRAM buildup and crashes across long generation sessions.
Notes
- If your ComfyUI server runs on a different machine than the one executing this code, you may need to hardcode the host/port in
free_cache_node.pyinstead of relying on the auto-detected server address. - Unloading the model every run means a reload cost each generation. If you're batching multiple prompts on the same checkpoint and want to avoid this, only enable the node on the last run of a batch rather than every single one.
License
MIT — see LICENSE.