Free Memory (Model)
A manual VRAM flush for multi-checkpoint workflows
- model
- MODEL
ComfyUI is already pretty good about managing VRAM on its own - it loads what a run needs and evicts what it doesn't, without you touching a flag. Free Memory (Model) exists for the workflows where that automatic handling isn't enough: base-then-refiner setups that swap checkpoints mid-graph, checkpoint-comparison loops, or anything where a MODEL finishes its job and you want its VRAM back before the next heavy step, not whenever ComfyUI gets around to it.
What it does
It's a pass-through. You wire a MODEL in, it runs a memory cleanup, and the exact same MODEL comes out the other side unchanged. The point isn't to transform anything - it's to plant a forced cleanup checkpoint at a specific spot in your graph, which is something the auto-evict behavior can't give you.
Under the hood, standard mode runs torch.cuda.empty_cache() (releases VRAM PyTorch is holding but not using) plus a Python gc.collect() for system RAM. Flip the aggressive input to True and it also calls comfy.model_management.unload_all_models() and a soft cache empty before the CUDA clear - a much harder reset that drops every model ComfyUI has cached, not just the one wired through this node. On Linux, aggressive mode additionally flushes filesystem buffers and pagecache; on Windows it trims the process working set via the Windows API. Either way it logs before/after memory numbers so you can actually see what got freed instead of guessing.
The inputs and outputs that matter
Only two inputs, and they're both dead simple:
model- theMODELyou're routing through. Required, this is the whole point of the node.aggressive- boolean, defaults toFalse. Standard mode is the "cheap and safe" option; aggressive is the "actually reclaim everything" option, at a cost (below).
Output is a single MODEL, identical to what went in. Wire it straight into whatever normally consumes the model - a KSampler, a LoRA loader, the next checkpoint's pipeline.
Installing it
Through ComfyUI Manager: search ComfyUI-FreeMemory, install, restart. By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/ShmuelRonen/ComfyUI-FreeMemory
pip install psutil
Restart ComfyUI. That's the entire dependency list - psutil, nothing else, no model downloads. All five nodes in the pack (Model, CLIP, Latent, Image, String) install together since they live in one repo.
Where people get burned
The honest take: don't wire this in by default on every model output out of habit. Aggressive mode unloads everything ComfyUI has cached, which means the next node that needs a model pays a full reload - from the KB's own memory-management lore, the community's repeated finding is that people slap on low-VRAM helpers reflexively and lose more time to reload/rebuild overhead than they ever saved. If your workflow already fits in VRAM and runs fine, this node (especially aggressive mode) can make it slower, not faster. Reach for it only when you're actually hitting OOM or genuinely need the headroom mid-graph - checkpoint-swap loops and base→refiner chains are the real use case, not every sampler.
Second: this node clears caches and unloads models, it does not fix an actual memory leak. If VRAM or RAM climbs steadily across a batch run even with this wired in, that's a leak somewhere else in the graph (usually a specific custom node not releasing tensors), and no amount of cache-emptying downstream will patch it - you're clearing the couch cushions, not fixing the hole in the couch.
Third, a structural one worth knowing: this node calls into comfy.model_management internals directly. Those are ComfyUI's own APIs and they occasionally shift between core versions. If you update ComfyUI and this node suddenly errors on an attribute that used to exist, that's the risk you take with any pack touching internal memory-management functions rather than the public node API - check the pack's GitHub issues before assuming your install is broken.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| aggressive | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |