Nodes/ComfyUI_Inteliweb_nodes/Free Memory (Inteliweb)
ComfyUI Node

Free Memory (Inteliweb)

A pass-through node that cleans house between stages

By maoper11·Created about a year ago·Updated 9 days ago· 4
Free Memory (Inteliweb)
  • anything
  • anything
  • STATS
purge_cachetrue
purge_modelsfalse
gc_collecttrue
console_logtrue
stage_nameMemory Cleanup

Long workflows - video passes, multi-stage img2img, big upscale chains - have a habit of dying halfway through with a CUDA out-of-memory error that has nothing to do with your model being too big and everything to do with five stages' worth of cached junk stacking up in VRAM. Free Memory is the answer: a pass-through node you drop between heavy stages that deliberately cleans up before the next one runs. The input comes in untouched, the cleanup happens, and a text report tells you what it did.

How it works

It's honest about what it does. The backend calls ComfyUI's own memory management: unload_all_models() if you ask it to, gc.collect() for Python garbage, and soft_empty_cache() to clear the accelerator cache. Nothing exotic, no process spawning - it's the same cleanup you'd trigger by hand, wrapped in a node with switches. The anything input (wildcard *) passes straight through to the anything output, so it slots into any graph without disturbing your data flow - that's the "pass-through" promise, and it's verified in the source: whatever goes in comes out byte-for-byte the same. The STATS output is a text report with VRAM/RAM before and after, models unloaded, objects collected, and cache state.

The inputs that matter.

  • purge_cache (default on) - clears the accelerator cache via soft_empty_cache(). This is the daily-driver setting.
  • purge_models (default off) - actually unloads ComfyUI-managed models. Leave it off unless you're about to run a stage that doesn't need the current models, because the next node that wants them will just reload them (and pay the loading cost again).
  • gc_collect (default on) - runs Python's garbage collector.
  • console_log (default on) - mirrors the report to the console.
  • stage_name - a label for the report, so when you have three of these in a workflow you can tell which cleanup a "Memory Cleanup" stat belongs to.

Installing it

It's part of the Inteliweb pack:

cd ComfyUI/custom_nodes
git clone https://github.com/maoper11/comfyui_inteliweb_nodes.git
cd comfyui_inteliweb_nodes
python -m pip install -r requirements.txt

ComfyUI Manager: "ComfyUI_Inteliweb_nodes". Only psutil + nvidia-ml-py, no models, restart.

Where people get burned

The big one is expectation: this frees memory, it doesn't prevent the next node from allocating whatever it needs. If your graph genuinely exceeds VRAM at peak, cleanup between stages can sometimes buy you just enough headroom, but it's not a substitute for a smaller model or a GGUF quant. Second, purge_models off-by-default surprises people who expect "free memory" to mean "unload everything" - it deliberately isn't, because unloading models you're about to reuse is pure waste. And one release note to know: STATS is text now (v0.20.1 simplified it from multiple numeric sockets), so if you were expecting numbers to wire into a display node, read the string instead. It's adapted from LayerStyle's PurgeVRAM concept, and for the "my long workflow OOMs at step 300" problem it's a genuinely useful safety valve.

CategoryInteliweb/Utils

Inputs (6)

NameTypeDefaultDescription
anything*
purge_cacheBOOLEANtrue
purge_modelsBOOLEANfalse
gc_collectBOOLEANtrue
console_logBOOLEANtrue
stage_nameSTRINGMemory Cleanup

Outputs (2)

NameTypeDescription
anything*The original input value, passed through unchanged.
STATSSTRINGText report with VRAM, RAM, model unload, garbage collection and cache results.