Free Memory (String)
The odd one out in the FreeMemory pack, and when it's worth it
- STRING
Let's be upfront about this one: a STRING - a prompt, a caption, a filename - is a few hundred bytes at most. Freeing "the memory it uses" isn't really the point, because there's basically nothing to free there. What Free Memory (String) actually gives you is a checkpoint you can drop on the text branch of a graph to trigger a memory cleanup at that point in execution order - useful when a text-generation step (a local LLM captioner, a batch prompt loop) shares the same GPU as your image pipeline, and you want a cleanup to happen right when that text output lands, not whenever some other node incidentally triggers one.
What it does
It's built on the same pattern as the other four nodes in this pack (Model, CLIP, Latent, Image): take a typed input, run a memory cleanup as a side effect, hand the same value back out unchanged. Here the "typed input" just happens to be text, which is why the memory-freed part of the story is almost beside the point - the real value is where in the graph the cleanup fires, since ComfyUI executes nodes in dependency order and this node lets you pin a cleanup to a specific string output.
Standard mode runs torch.cuda.empty_cache() for VRAM and gc.collect() for system RAM - same as the rest of the pack, and about as cheap as memory cleanup gets. aggressive=True adds comfy.model_management.unload_all_models() and a soft cache empty before the CUDA clear, unloading every model ComfyUI currently has loaded - checkpoint, CLIP, VAE, all of it - regardless of the fact that a string doesn't need any of that memory back. On Linux that also flushes pagecache (may need elevated privileges); on Windows it trims the process's working set. Both modes log before/after memory usage.
The inputs and outputs that matter
string- the text you're routing through. Required.aggressive- boolean,Falseby default.
Output is a single STRING, identical to the input. Wire it onward to wherever the text goes next - a CLIPTextEncode prompt input, a save-metadata node, a filename field.
Installing it
ComfyUI Manager: search ComfyUI-FreeMemory, install, restart. Manual install:
cd ComfyUI/custom_nodes
git clone https://github.com/ShmuelRonen/ComfyUI-FreeMemory
pip install psutil
Restart ComfyUI. psutil is the only dependency, and cloning the repo gets you all five FreeMemory nodes, not just this one.
Where people get burned
Honestly, this is the node in the pack most likely to be dead weight in a typical workflow - if your graph is a normal prompt-to-image pipeline, wiring a cleanup node onto the prompt string does nothing meaningful, because the string was never the thing eating your memory. It earns a place specifically in graphs where a text-producing step - a local captioning model, an LLM node generating prompts in a batch loop - is competing for VRAM with your diffusion pipeline, and you want a forced cleanup right after that text lands and before the image side claims memory. Outside that case, skip it.
And the aggressive-mode caution applies here as much as anywhere: it doesn't scope to "the model that produced this string," it unloads everything ComfyUI has cached, which forces a full reload downstream. On a plain text field that rarely needed a cleanup in the first place, that's a cost with no matching benefit - leave aggressive off unless you're actually watching memory climb across a batch. And as with the rest of the pack, this clears caches, not leaks: if RAM keeps growing across a run regardless, the leak is elsewhere in the graph, not in the string this node happens to be sitting on.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — | |
| aggressive | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |