🔥 Dynamic RAM Cache Control
ComfyUI's RAM Cache Got Teeth — This Node Is the Valve
- any_input
- output_passthrough
ComfyUI started caching model outputs in your system RAM back in late 2025 (the RAMPressureCache / --cache-ram feature), and it's quietly one of the best things to happen to iteration speed - until it isn't. The deal: re-run a workflow with a new seed, or switch back to a workflow you generated an hour ago, and ComfyUI serves cached node outputs from RAM instead of recomputing. On a 64 GB box that's pure win. On 16–32 GB, the cache grows until your OS starts swapping and everything crawls, which is exactly the "RAM is maxed out and I have to restart ComfyUI" complaint you see all over the subreddit.
This node is the in-workflow valve for that cache. You get to say how much free RAM to keep, which cache mode to run, and when to force a purge - all from inside the graph, per prompt, instead of restarting ComfyUI with different flags.
How it works
DynamicRAMCacheControl is invasive by design. When it executes, it goes hunting through Python's garbage collector for the live PromptExecutor object, then mutates the executor's cache_args - the ram and ram_inactive values that map to the --cache-ram active inactive startup pair - and swaps the executor's cache set between the two cache classes:
- CLASSIC (No Eviction) uses
HierarchicalCache: normal caching, never auto-purging. - RAM_PRESSURE (Auto Purge) uses
RAMPressureCache: ComfyUI can release cache after each node, and the node itself triggers an active purge down to your thresholds, evicting oldest/least-recently-used entries first.
The smart part is that a mode switch migrates your existing cached entries into the new cache object instead of nuking them - you don't lose your cache just because you changed modes mid-prompt. And because it pokes at internals, it needs a ComfyUI build with RAMPressureCache in it (upstream since 2025-10-31) and it's worth keeping ComfyUI updated, since the node has compatibility logic that tracks how recent builds handle the RAM release callback.
The inputs that matter
Three of them, and you'll touch maybe two:
mode- CLASSIC or RAM_PRESSURE. If you're here because RAM keeps climbing, this is RAM_PRESSURE.cleanup_threshold(GB, default 2.0) - the active-cache headroom: how much free RAM to maintain. This is the first--cache-ramvalue. Frequent purging = raise it; tight RAM = lower it.inactive_threshold(GB, default 0) - the pinned-memory headroom (the second--cache-ramvalue).0means "leave ComfyUI's current value alone," which is the right call on older builds that ignore it.
The any_input is a passthrough. Feed anything in and it comes back out the output_passthrough output unchanged; wire nothing in and it emits an ExecutionBlocker, so the node can sit in the graph and "return nothing" - handy if you just want it to run its purge and keep the rest of the graph moving.
Install
No model files, no dependencies beyond ComfyUI itself - the pack's only "requirement" is a recent-enough ComfyUI build. Two ways:
- ComfyUI Manager → "Install Custom Nodes" → search
ComfyUI_Dynamic-RAMCache. - Or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/Windecay/ComfyUI_Dynamic-RAMCache
Restart ComfyUI either way. The nodes land under utils/dynamic_ramcache.
Gotchas
Watch the console. If you see "executor mode kept as CLASSIC", your ComfyUI build stores a prompt-local RAM release callback and switching executor mode mid-prompt would throw NoneType object is not callable - the node deliberately leaves the mode alone, but thresholds, migration, and the active purge still run. If you see "CLASSIC requested, RAM_PRESSURE kept active", that's the same guard: newer builds default to RAM cache, so the node ignores a CLASSIC request mid-prompt. That's not a bug, that's the safety rail. If you genuinely need to turn RAM caching off, that's a startup-flag or global-settings change, not something this node can force mid-run.
One more honest caveat: this is a young, niche tool (the pack dates to the RAM-cache era itself), and it reaches into ComfyUI's plumbing. If ComfyUI updates and you start seeing warnings, update ComfyUI and this pack before assuming your workflow broke.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| mode | COMBO | RAM_PRESSURE (Auto Purge) | 2 options: CLASSIC (No Eviction), RAM_PRESSURE (Auto Purge) |
| cleanup_threshold | FLOAT | 2.00.1–256 | Active cache free RAM threshold (GB) |
| inactive_thresholdopt | FLOAT | 0.00–256 | Inactive cache / pinned memory threshold (GB). 0 keeps ComfyUI's current value. |
| any_inputopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output_passthrough | * | — |