GarbageCollect-badger
A manual 'empty the VRAM cache' button for long, bloated runs
- STRING
Every now and then a workflow eats VRAM like it's got a grudge, and the usual answer - "ComfyUI manages that for you" - stops feeling true. GarbageCollect-badger is the explicit version: a node you drop into the graph that calls torch.cuda.empty_cache(), collects Python garbage, and frees the CUDA cache right now, mid-workflow. It's a manual reset button for memory pressure, placed exactly where you need it.
The honest framing first: ComfyUI already frees VRAM between queues, and every node in this pack calls a garbage-collect routine after it finishes anyway. So this node is not fixing a normal workflow. It's for the edge cases: long chains where you load a big model, unload it, and the next model won't fit because fragmentation and cached allocator blocks are still holding memory; or a run that's clearly bloating as it goes and you want a clean point before the heavy part starts. The troubleshooting playbook for "out of memory" is usually "reduce batch size, switch to fp16," but a strategically placed cache-emptier genuinely helps when the issue is allocator cruft rather than genuinely needed tensors.
How it works
It calls the same cleanup routine the pack's other nodes call internally: torch.cuda.empty_cache(), a CUDA IPC collect, and gc.collect(). Nothing else. The two required inputs, start (a dummy STRING) and seed (an INT), don't influence anything - seed is entirely unused, and start is just a trigger value that the node passes straight through. The node is marked as an output node, so ComfyUI treats it as a graph endpoint and runs it even if nothing downstream consumes it - that's the design: drop it in the middle of a chain as a side-effect step.
It returns the start string unchanged. Ignore the output; the output was never the point.
Inputs
- start - STRING, default "start". Pass-through. Wire anything into it.
- seed - INT, unused. Change it, don't change it; it does nothing.
One output: the start string, unchanged.
Installing it
In ComfyUI_BadgerTools: ComfyUI Manager → search "BadgerTools" → install, or
cd ComfyUI/custom_nodes
git clone https://github.com/AbyssYuan0/ComfyUI_BadgerTools
Restart after install. No models. The pack's heavy requirements import at startup regardless - that's the usual cost of grabbing a node out of this pack.
When it helps, when it doesn't
It helps when the problem is cached-but-unused memory. It does nothing if the memory is genuinely occupied by tensors you still need on the graph. And empty_cache isn't free: refilling the cache costs a bit of time on the next allocation. So place it at a boundary - after a model is unloaded, before the next heavy load - rather than in the middle of a hot loop.
Also honest about limits: this pack's own nodes auto-flush memory after every run, which is the author's way of being tidy. If your workflow already uses several badger nodes, you're already getting the effect. This one just makes it explicit and lets you choose where.
No community threads exist for this node - it's a personal-pack utility, and you're not missing a settings guide. The node has one job, and the job is "make memory stop being a problem right here." Sometimes that's exactly the tool.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| start | STRING | start | — |
| seed | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |