Free Memory (Image)
A cleanup checkpoint for long image and video batches
- image
- IMAGE
If you're running a single image through a single sampler once, you'll never notice this node exists - ComfyUI's own memory handling covers that case fine. Where Free Memory (Image) actually matters is longer chains: upscalers, face-restoration passes, frame-by-frame video pipelines, or any loop where images keep piling through the graph and you want a deliberate cleanup point rather than waiting for the next model load to trigger one.
What it does
It's the image version of a pattern that runs through this whole pack (Model, CLIP, Latent, Image, String all work identically): pass a typed value in, run a memory cleanup as a side effect, hand the exact same value back out. The IMAGE tensor isn't touched - the node clears memory around it, at whatever point in the graph you've placed it.
Standard mode calls torch.cuda.empty_cache() to release VRAM PyTorch is holding but not using, plus a Python gc.collect() for system RAM. Flip aggressive to True and it also runs comfy.model_management.unload_all_models() and a soft cache empty ahead of the CUDA clear - dropping every model currently loaded in ComfyUI, not just whatever generated this particular image. On Linux, aggressive mode additionally flushes filesystem buffers and pagecache (may need elevated privileges to be fully effective); on Windows it trims the process's working set via the Windows API. Both modes report memory usage before and after so the cleanup is visible rather than assumed.
The inputs and outputs that matter
image- theIMAGE(or image batch) you're routing through. Required.aggressive- boolean,Falseby default. Standard mode is the low-risk cache clear; aggressive is the full reset with the reload cost that comes with it.
Output is a single IMAGE, unchanged from the input. Wire it into whatever's next - a Save Image node, another postprocessing step, or a Video Combine node if you're chaining frames.
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. psutil is the only dependency, there's nothing to download, and the clone gives you all five FreeMemory nodes at once.
Where people get burned
Same caution that applies to every node in this pack: aggressive mode isn't scoped to the image passing through it, it unloads everything ComfyUI has cached. Drop it into every step of a video-frame loop with aggressive=True and you're forcing a full model reload on every single frame - which will slow your batch down far more than the memory it reclaims saves you. The pattern to actually reach for is placing one Free Memory (Image) node, standard mode, at a real seam - after a heavy upscale pass and before the next stage - and saving aggressive for the rare case you're genuinely watching VRAM creep toward the limit across a long run.
It's also worth being clear-eyed about what this fixes and what it doesn't. It clears PyTorch's cache and forces garbage collection; it does not patch an actual memory leak. If RAM or VRAM keeps climbing steadily across a batch even with this node wired in after every frame, that's a leak somewhere upstream - commonly a custom node not releasing tensors it's done with - and no amount of downstream cache-clearing fixes that; you'll need to find and fix the actual source. And because this node calls into comfy.model_management directly rather than a stable public API, a ComfyUI core update can occasionally break it if those internal functions change - worth checking the pack's GitHub issues before assuming it's your setup.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| aggressive | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |