Nodes/FxAi(凤希全能节点)/凤希AI - 清理缓存
ComfyUI Node

凤希AI - 清理缓存

Garbage collection. That's the whole point.

By fxai666·Created 7 months ago·Updated 2 days ago· 47
凤希AI - 清理缓存
  • anything
  • output

The two cleanup nodes, and why the boring one matters

This pack ships two nodes in 凤希AI/清理 that look interchangeable at a glance. They are not. FxAiCleanGpu unloads every model and empties the CUDA pool - a big hammer that costs you a reload. FxAiClearCache (凤希AI - 清理缓存) runs one line:

gc.collect()

That's it. Python garbage collection. No CUDA call, no model unload, no ComfyUI cache surgery.

Which sounds useless until you've spent an afternoon watching a video workflow creep from 12GB of system RAM to 60GB across iterations while nvidia-smi looks perfectly innocent. That growth is Python-side: PIL frames, numpy buffers, decoded audio, per-segment tensors that went out of scope but whose reference cycles haven't been collected yet.

Why it's so deliberately narrow

The author put the reasoning in the docstring, and it's the most useful paragraph in the file. The node does not touch ComfyUI's execution cache, because invalidating that doesn't save memory - it makes the downstream graph re-run, which is work you already paid for. And it does not unload models, because the next iteration would have to copy those weights back into VRAM.

So the design is scoped to exactly one failure mode: Python objects that should have died and haven't. When a long loop leaks, this is the cheap tax that keeps it alive.

Inputs and outputs

One input, anything (wildcard), one output, output (wildcard), value unchanged. Same author tooltip as its sibling: connect the last link's output, the node cleans up and leaves your data alone.

The input is there for ordering. Execution order in ComfyUI follows the dependency graph, so the only way to say "collect garbage after this stage" is to make this node depend on that stage's output. Pick something small - an index, a frame count, the last latent - because anything you wire in stays referenced for as long as the pass-through holds it, which is the opposite of what you're trying to achieve.

It's an output node, so it fires on every queue even if nothing downstream cares.

In practice it belongs at the bottom of a loop body: decode segment → process → save → clear cache. Two of these per iteration cost you microseconds and buy back the headroom that makes a 40-iteration video run finish instead of dying at iteration 26. Ignore what memes say about "clearing cache" making things faster - this doesn't speed anything up, it just keeps the process from bloating.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/fxai666/fxai-toolkit

Then restart ComfyUI. ComfyUI Manager works too - search fxai-toolkit (publisher fxai). The pack auto-installs soundfile and psutil on import; psutil is what its memory pre-checks use, so don't fight it.

No models, no weights, nothing in models/ to download for this node.

Where it bites

Don't expect the numbers to move. If you watch VRAM or process RAM after this node and see nothing change, the node worked - there was nothing cyclic to collect. Reading the pass-through as a no-op is the normal case.

It gets confused with the GPU one. Both take anything, both are in 清理, both pass through. Search the exact class name when you're wiring a shared workflow; picking the wrong one inside a loop is how you get a 20-minute run that spends 15 minutes reloading checkpoints.

Node doesn't appear after install. The pack registers each node individually inside try/except and prints ❌[凤希AI] 节点加载失败 for anything that failed to import, so a single missing dependency hides one node without any loud error. Read the console at startup, then restart.

It is not a fix for a genuine leak. If your loop holds a reference to every frame it ever made - say, an accumulator you keep appending to - gc.collect() will correctly determine that memory is still in use. Nothing here can help you; the loop body needs to stop growing.

Category凤希AI/清理

Inputs (1)

NameTypeDefaultDescription
anything*接上一环的输出,本节点只负责清理,不动数据。

Outputs (1)

NameTypeDescription
output*—