Nodes/Sage Utils/Free Memory
ComfyUI Node

Free Memory

The panic button for your VRAM, wired right into the graph

By arcum42·Created 2 years ago·Updated 28 days ago· 33
Free Memory
  • value
  • value
free_memoryfalse

The name is the whole pitch. Free Memory is a pass-through node with a toggle: wire anything through it, flip the switch, and it unloads every loaded model, runs garbage collection, and empties ComfyUI's caches. You've probably been reaching for "Clear" in the settings menu and losing your whole graph context to do this. This node does it at a specific point in your workflow, without you leaving the canvas.

The mechanism is straight out of ComfyUI's own model management. When free_memory is on, the node calls unload_all_models(), then gc.collect(), then soft_empty_cache(). That's the same trio you'd invoke manually when a generation OOMs: kick the models out of VRAM, run Python's garbage collector, and tell ComfyUI to stop holding freed blocks. The value input is untouched - whatever you feed in (a latent, an image, a string, doesn't matter, it accepts any type) comes back out on the value output unchanged. The node is just a convenient place to hang a memory-clearing event off the graph's execution order.

Where this actually earns its place: workflows that chain heavy things ComfyUI would otherwise keep resident. Say you generate a batch, then want to run a big VAE decode on the results, or you're loading a LoRA-heavy checkpoint after a ControlNet preprocessing pass. Sticking a Free Memory node on a wire that executes between the two steps frees VRAM right when you need it. Same trick for people juggling an LLM and a diffusion model on one 16GB card - a genuinely common Sage Utils scenario, since this pack ships its own LLM integration that also wants VRAM. It won't fix a fundamentally too-big setup, but it smooths the juggling.

Two things to know before you sprinkle these everywhere. First, "unload all models" means exactly that: the next node that needs the checkpoint will reload it from disk, and that reload is slow. Put the node where you actually need headroom, not on every wire out of habit. Second, soft_empty_cache is a soft clear - ComfyUI's memory manager will re-grab those buffers happily, which is the point, but it also means this is a temporary reprieve, not a leak fix. If you're OOMing every run, the answer is a smaller model or a quantized one, not more Free Memory nodes.

Install

ComfyUI Manager is the easy road - search for Sage Utils and install. Or, the manual way:

cd ComfyUI/custom_nodes
git clone https://github.com/arcum42/ComfyUI_SageUtils.git
cd ComfyUI_SageUtils
pip install -r requirements.txt

Then restart ComfyUI. The only real Python dependency is dynamicprompts, so install is painless. One quirk of this pack: at startup it tries to reach local LLM servers (LM Studio / Ollama) and will log connection warnings if they're not running - harmless, just noisy. Set SAGEUTILS_LOG_LEVEL=WARNING when you launch ComfyUI to quiet it down.

If you're running into OOMs before this node ever executes, remember the ComfyUI flags that actually change memory behavior: --reserve-vram to cap how much VRAM ComfyUI grabs, and quantized (GGUF) checkpoints as the real lever on small cards. Free Memory is the band-aid; those are the fix.

CategorySage Utils/util

Inputs (2)

NameTypeDefaultDescription
free_memoryBOOLEANfalseUnload models and clear caches when enabled.
value*Optional value to pass through unchanged.

Outputs (1)

NameTypeDescription
value*The passed-through value after optionally freeing memory.