🧹 RAM Purge by Steve Lasmin
The heavy hammer that gives ComfyUI its RAM back on Windows
- trigger
- trigger_out
Chain a checkpoint, a 13B video model like LTX-2, and a VAE decode into one workflow and your 32 GB machine starts crawling. ComfyUI deliberately caches every model it loads - reloading weights is the slow part of a workflow, so it holds on to what it has. That's great until Task Manager shows your system RAM pegged and the machine starts swapping mid-generation. r/StableDiffusion is full of threads titled "ComfyUI holding onto RAM" for exactly this reason.
This node is the aggressive answer to that. It's the heavy sibling of the pack's VRAM Purge: instead of just emptying the CUDA cache, it clears ComfyUI's model caches, forces a deep garbage collection, and then does something ComfyUI never does on its own - trims the Windows working set so the OS actually pages unused physical RAM back to the pagefile.
How it works
Like the VRAM node, it's a passthrough: wire anything into trigger, get the same thing out of trigger_out. The cleanup happens when execution reaches it, in a specific order:
- Safety gate - the
confirmationfield must readPURGE(all caps, and that's the default) or the whole thing skips. The author's own tooltip says why: an accidental purge forces slow re-loading of every model you just kicked out. - Cache clearing - it clears ComfyUI's internal
loaded_modelsandcurrent_loaded_modelslists, then calls ComfyUI's officialunload_all_models()andsoft_empty_cache(). - Aggressive mode - three passes of
gc.collect()to catch reference cycles, plus clearing thecomfy.sdmodel cache, the CLIP cache, and the torch autocast cache. - CUDA -
empty_cache()twice with asynchronize()between them. - The Windows part -
SetProcessWorkingSetSize(-1, -1)/EmptyWorkingSet, which tells Windows to page the process's working set out to the pagefile.
That last step is the differentiator. Unloading models moves weights from VRAM back into system RAM, which briefly makes your RAM usage worse; the working-set trim is what actually pushes that RAM to the pagefile and drops the number in Task Manager. It only affects the ComfyUI process's own committed memory - it's a trim, not a miracle.
The inputs that matter
Three booleans, all default on, all fine left on:
aggressive_mode- the deep GC and cache-wipe pass. The tooltip calls it "recommended for LTXV-2.3 workflows," and it's what makes this node more than justunload_all_models().clear_cuda_cache- empties the CUDA cache, i.e. the VRAM side of the purge.trim_working_set- the Windows working-set trim. This is the one that changes the numbers you see in Task Manager.
Plus confirmation (the PURGE safety gate) and the trigger input. There's one output, trigger_out, which you just wire onward to keep the graph flowing.
Where it earns its place
The intended workflow is spelled out in the README: place it between heavy model-loading stages so models don't stack up in RAM - checkpoint → purge → video model → purge → VAE decode. That's a legit use. What it is not, and I want to be blunt here: a cure-all. The community is genuinely split on whether RAM-purge nodes help - one recent thread on the subject has users saying "even the vram cleanup nodes don't do the trick for me," and the working-set trim demonstrably reduces committed RAM but doesn't touch memory that's actively in use. Every purge also means paying the reload tax on the next model load, which is why the author warns you about "slow re-loading of subsequent models." Use it where models genuinely stack up, not between every pair of nodes.
Installing it
ComfyUI Manager: search for "RAM/VRAM Purge by Steve Lasmin" and install. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Eklipsis/comfyui-ram-vram-purge-by-steve-lasmin.git
Restart ComfyUI. No dependencies - the pack's pyproject.toml lists none. It shows up under RAM/VRAM Purge by Steve Lasmin.
Troubleshooting
- Nothing happens when it runs. Check the
confirmationfield. If you retyped it in lowercase or deleted it, the node silently skips - it prints a note to the console and still passes data through, so it's easy to miss. - You see "Warning clearing loaded_models" in the console. This node pokes at ComfyUI internals whose names change between versions. It's wrapped in try/except, so it logs and moves on rather than crashing - harmless, but a sign ComfyUI's internals moved on.
- "All working-set trim methods failed." The ctypes Windows calls didn't get the handle they wanted. Rare, but the node tells you when it can't trim.
- On Linux or macOS. The working-set trim and RAM stats skip gracefully; the cache-clearing still runs. This is genuinely a Windows-first node, though.
- Things got slower, not faster. That's the reload tax. You're purging models you're about to load again - place the node less aggressively.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| trigger | * | Connect any wire here to trigger the purge when execution reaches this node. The data passes through unchanged. | |
| aggressive_mode | BOOLEAN | true | Runs deep cleanup: 3-pass garbage collection, clears internal ComfyUI caches (sd, clip_model), and torch autocast cache. Recommended for LTXV-2.3 workflows. |
| clear_cuda_cache | BOOLEAN | true | Empties the CUDA cache twice and synchronizes the GPU. Essential for freeing VRAM after heavy model loads. |
| trim_working_set | BOOLEAN | true | Uses Windows SetProcessWorkingSetSize / EmptyWorkingSet to force the OS to page out unused physical RAM back to the pagefile. This is what actually reduces the number you see in Task Manager. |
| confirmationopt | STRING | PURGE | SAFETY GATE: Type the word PURGE (all caps) to execute. Prevents accidental clicks that would force slow re-loading of subsequent models. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| trigger_out | * | — |