Josia缓存清理
The housekeeping node that frees your VRAM without evicting your model
- 任意
- 输出
JosiaCacheCleanup (Josia缓存清理) is a tiny node whose only job is to make the second run of a workflow faster. You drop it anywhere in the graph, it frees the VRAM and RAM that the previous generation left lying around, and - the whole point - it does not unload your model. Models, CLIP, and VAE stay resident, so when you queue again you skip the reload wait.
The name is a lie in the good way. "缓存清理" makes it sound like it nukes your caches, but the README is careful to say what it actually does: it releases unreferenced intermediate tensors and idle VRAM fragments from the last generation, while anything a live model still points at survives untouched. Think of it as tidying the desk rather than emptying the room.
How it works
Under the hood it calls the same two things you'd reach for by hand in a Python console: gc.collect() to run Python's garbage collector, then comfy.model_management.soft_empty_cache() - the ComfyUI wrapper for torch.cuda.empty_cache() that only returns free blocks to the driver. Because the caching allocator keeps model weights in use, soft_empty_cache reclaims the slack without forcing ComfyUI to reload the checkpoint on the next run.
Two switches, both with Chinese labels:
- 清理无用缓存 (clear useless cache) - default on. The standard pass:
gc.collect()+soft_empty_cache(). - 深度回收 (deep reclaim) - default off. Adds a second
empty_cacheand gc pass for when VRAM still reads high. It's more thorough but every reallocation after it costs a little time, which is why the author leaves it off by default.
Both are safe to leave at defaults and just forget about.
Inputs and outputs
It's a pass-through node: an optional 任意 (any-type) input and a single 输出 (output) that returns whatever you feed it, byte for byte. Wire it into any convenient spot - even run it standalone as an output node - and it just sits in the data flow doing housekeeping. No data gets transformed, so you can't break a workflow by adding it.
Install
This pack ships with zero extra Python dependencies - the requirements file literally says "no additional dependencies," everything is ComfyUI built-ins. Either install via ComfyUI Manager (search ComfyUI_JosiaNodes), or:
cd ComfyUI/custom_nodes
git clone https://github.com/Josia-doit/ComfyUI_JosiaNodes
Then restart ComfyUI. You'll know it loaded when the console prints [JosiaNodes] ✅ JosiaNodes 加载成功,注册节点数:12.
Honest expectations
This is a micro-optimization, not a fix. On a 8GB card doing image-to-image loops, keeping the model resident genuinely shaves seconds off every rerun. But if your real problem is that you're constantly out of VRAM, this node won't save you - it frees garbage, not a 12GB model you can't fit. For that you want model offloading, a GGUF quant, or a smaller resolution, not a cleanup node.
Where people get burned: expecting it to unload something. It can't, by design. And note the whole pack is labeled in Chinese - every node and widget in JosiaNodes is Chinese-first, which is fine, just don't hunt for "Cleanup VRAM" in the menu; it lives under the Josia category.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| 清理无用缓存 | BOOLEAN | true | 释放上一次出图残留的显存碎片与无引用中间张量; 已加载的模型/CLIP/VAE 保持常驻(不卸载), 重复运行工作流时无需重新加载,速度更快。 跨平台安全:无 GPU 时自动跳过显存清理,仅做内存回收。 |
| 深度回收 | BOOLEAN | false | 在「清理无用缓存」基础上,额外 torch.cuda.empty_cache() + 二次 gc,释放更彻底; 代价:下次张量分配有少量重新分配开销, 仅在显存仍明显偏高时开启,平时保持关闭。 |
| 任意opt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 输出 | * | — |