ComfyUI Node

🧹 kmlbdh RAM Cleaner

The memory-flush passthrough you drop in before RIFE

By kmlbdh·Created about a year ago·Updated 12 months ago· 5
🧹 kmlbdh RAM Cleaner
  • images
  • IMAGE
message🧹 kmlbdh RAM Cleaner: Cache cleared

🧹 kmlbdh RAM Cleaner is the pack's answer to a very specific ComfyUI feeling: your graph is heavy, you're about to hit RIFE or another VRAM-hungry node, and you'd pay good money for a "please don't explode" checkpoint. That's what this node is - a passthrough that does nothing to your images and, in between, begs Python and PyTorch to give memory back.

What it is and what it isn't

It takes an IMAGE batch, prints a log message, forces a garbage collection, clears PyTorch's CUDA cache, synchronizes the GPU, and hands you back the exact same images. Your frames pass through untouched. It is not a standalone "clean now" button - because it requires an IMAGE input, it has to sit in the data path of your workflow. You wire your frames through it on the way to the next node, and it's that simple.

The author's own framing is honest and useful: "Use after Upscale or before RIFE to prevent crashes." That's the entire job.

Does it actually work?

Mostly, sort of, sometimes. Here's the mechanism, level with you:

  • gc.collect() frees Python objects that are unreachable. Useful, but tensors that are still referenced by the graph aren't going anywhere.
  • torch.cuda.empty_cache() returns PyTorch's cached memory blocks to the CUDA driver. That genuinely relieves allocator pressure right before a big op - the "OOM" you see at the end of a run is often fragmentation, and a flush can buy you the headroom to get through one more node.
  • The catch: ComfyUI already manages VRAM, and empty-ing the cache means the next allocation has to be re-requested. On a graph that's already at its limit, this can make things slower even when it prevents the crash.

So treat it as a "panic button in graph form" rather than a fix. If a workflow dies on you every time at the same spot, dropping one of these in before that spot is a legitimate thing to try - I've seen it get finicky pipelines unstuck. But it won't rescue a graph that's fundamentally too big for your card; that's a workflow problem, not a memory-cleaning problem, and no passthrough node is going to change it.

The inputs

Just two, and only one is real work:

  • images - the frame batch you want to flush memory around. Required, and it's your return ticket: the node outputs the same IMAGE.
  • message - a log string it prints to the console when it runs. The default is "🧹 kmlbdh RAM Cleaner: Cache cleared" and you can change it to whatever helps you read your logs. That's it.

Install and gotchas

It ships in the same kmlbdh/ComfyUI-kmlbdh-VideoCombine pack as the video exporter, so installation is identical: ComfyUI Manager → search "kmlbdh Video Combine (Smart + Tiled)", or git clone https://github.com/kmlbdh/ComfyUI-kmlbdh-VideoCombine.git into ComfyUI/custom_nodes, then restart. No requirements file, no model downloads.

Two things worth knowing before you adopt it. First, it only helps if you place it between heavy nodes - before RIFE, after an upscale - not at the end where it's a no-op. Second, it's a passthrough, so if you mute or bypass it to debug, your frames still flow and your graph still runs. That makes it cheap to experiment with. The pack is a small one-author affair, but this node is so small and self-contained that the risk of trying it is basically zero.

Categorykmlbdh

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE
messageSTRING🧹 kmlbdh RAM Cleaner: Cache cleared

Outputs (1)

NameTypeDescription
IMAGEIMAGE