VRAM/RAM Cleaner
Squeeze a bigger model into your VRAM mid-workflow
- any_model
- any_model
VRAM/RAM Cleaner is the node you drop in when ComfyUI's automatic memory management isn't aggressive enough for your card. It passes whatever you feed it through unchanged and, on the way, frees GPU and system memory so the next heavy step - a big VAE decode, a ControlNet pass, a 4MP latent - doesn't OOM. On an 8GB card doing multi-pass workflows, that one node in the right place can be the difference between a run that completes and one that dies at 90%.
How it works
The mechanism is honest ComfyUI plumbing rather than magic: it calls into comfy.model_management to unload models, empties PyTorch's CUDA cache (torch.cuda.empty_cache, plus IPC collect), and runs a garbage collection pass. The input is any single object - a MODEL, CLIP, VAE, or whatever - and it comes out the other end bit-for-bit the same, so the node is safe to splice into the middle of a data path.
The mode combo is the whole decision, and the names are slightly counterintuitive:
Current(default) - unloads just the object flowing through. Good when you're done sampling with a model and the next step is a giant decode.Others- unloads everything else in memory, then force-reloads the object you passed through so your pipeline keeps working. This is the one that actually frees room for the next model in line.All- empties the house. Use it between independent stages where nothing in memory matters anymore.
Output is the same any_model you put in.
Installing
Part of the ComfyUI-Flow-Assistor pack - ComfyUI Manager (search "Flow Assistor") or:
cd ComfyUI/custom_nodes
git clone https://github.com/Merserk/ComfyUI-Flow-Assistor.git
Restart after cloning. Requires a current ComfyUI (the pack is V3-only) and nothing else - no extra pip dependencies, no model downloads.
Where people get burned
The Current mode is the trap. If you route a model through it and then keep sampling with that same model, you've just unloaded the thing you're about to use; ComfyUI will reload it on demand, so you don't break anything - you just lose time, and on the first reload the VRAM you freed gets re-allocated anyway. The clean mental model: Current is for "I'm done with this object," Others is for "make room while I keep using this object." Also, the node is a passthrough in the data path, not a global switch - it only cleans when that branch of the graph actually executes. Put it on a branch that always runs, or ComfyUI's own memory management is doing all the work and this node is just decoration.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| any_model | COMFY_MATCHTYPE_V3 | — | |
| mode | COMBO | Current | 3 options: Current, Others, All |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| any_model | COMFY_MATCHTYPE_V3 | — |