Mie Loop State Cleanup Image ๐
Free a carried image from loop state
- loop_ctx
- loop_ctx
- cleaned
A memory-hygiene node for feedback loops. When you carry an image across iterations through the loop's shared state, MieLoopStateCleanupImage deletes that stored image once you're done with it, so it isn't held in memory for the rest of the loop.
Part of ComfyUI-MieNodes (ComfyUI_MieNodes), MieMieeeee's utility pack, under the ๐ Loop submenu.
Why you'd reach for it
The setup this exists for: an iterative-refinement loop. Each pass generates an image, stashes it in the loop state under a key (the default here is feedback_image), and the next pass reads it back to build on. That works - but if you never clear the stored image, you're holding a full-resolution tensor in the loop context, and across a long loop that's real VRAM/RAM pressure. Once a pass has consumed the carried image and produced its replacement, MieLoopStateCleanupImage drops the old one from the state, keeping memory flat instead of letting it creep.
This is a specialist node. If your loop doesn't carry an image through its state - most simple "generate one per input" loops don't - you don't need it. It earns its place specifically in feedback / img2img-chain patterns.
The inputs and outputs that matter
loop_ctx(MIE_LOOP_CTX) - the loop context to clean.key(STRING, defaultfeedback_image) - the name of the stored image to remove. It must match the key the image was saved under; the default assumes the conventionalfeedback_imageslot.
Outputs:
loop_ctx- the cleaned context, passed onward so the loop continues.cleaned(BOOLEAN) - whether there was actually something at that key to remove. Useful to confirm the cleanup landed rather than silently no-op'ing on a wrong key.
Installing it
ComfyUI Manager โ search ComfyUI-MieNodes โ install โ restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
then restart. No model downloads or heavy dependencies. Under ๐ MieNodes โ ๐ Loop.
Common issues
cleaned comes back false. Nothing was stored under that key. Either the image was saved under a different name, or it was never written to state in the first place. Match key to whatever your loop used to stash the image.
Memory still climbing. Cleaning the state image only frees that slot. If you're also collecting images every pass with MieLoopCollectImage, that's a separate accumulator - turn on its offload_to_disk to keep the collected set off the GPU.
I cleaned it too early. Sequencing matters: only run cleanup after the current pass has finished reading the carried image and produced its successor. Drop it before the image is consumed and the next iteration has nothing to build on.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ | |
| key | STRING | feedback_image | โ |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ |
| cleaned | BOOLEAN | โ |