Smart Memory Manager π§
The set-it-and-forget-it babysitter for ComfyUI
- management_status
- detailed_report
- management_active
- current_memory_usage
- last_action
- performance_stats
Most of the ComfyUI-MemoryManagement pack is manual buttons - you bump a trigger, something cleans up, you read a report. Smart Memory Manager is the one that babysits your session for you. Drop it in a workflow, give it some thresholds, and it runs a background loop that keeps an eye on your RAM and GPU, cleaning up when you cross a line and doing it automatically. It's the node you'd actually keep in a long-running setup, not one you fiddle with.
If you've had ComfyUI creep up to 99% RAM over a long session, or had a multi-hour batch die at hour three from accumulated garbage, this is the pack's attempt to make that not happen. It's the flagship node - it bundles cleanup, VRAM optimization, and leak detection into one config.
How it works
When you enable it, the node spawns a daemon thread that checks memory every check_interval seconds. Cross the warning threshold and it does a preventive cleanup; cross the critical threshold and it does an aggressive one (in Aggressive mode it'll even do maintenance passes when you're not over any threshold, just on principle). Optional extras on top: a tracemalloc-based leak detector that takes snapshots on its own schedule, and periodic VRAM optimization.
The inputs that matter
- enable_smart_management (BOOLEAN, default true) - the master switch.
- management_mode - Conservative / Balanced / Aggressive, default Balanced. Aggressive does more frequent, more thorough cleanup at higher overhead.
- memory_warning_threshold (60β90%, default 75) and memory_critical_threshold (70β95%, default 85) - your two lines in the sand. Keep them apart; if they're too close, every check feels like an emergency.
- check_interval (15β300s, default 45) - how often the loop wakes up.
- The optional toggles: enable_leak_detection (default true), enable_vram_optimization (default true), auto_cleanup_aggressive (default false), and leak_detection_interval (60β1800s, default 300).
Outputs
Six of them, mostly for display: management_status, detailed_report, and performance_stats are STRING readouts; last_action tells you what the loop most recently did (handy for confirming it's actually working); management_active (BOOLEAN) and current_memory_usage (FLOAT, current system RAM percent) are the ones you could wire into logic.
Installing it
Same story as the rest of the pack - no models, no heavy dependencies (just psutil; torch is already there). ComfyUI Manager β search "Memory Management" β install β restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/kaaskoek232/ComfyUI-MemoryManagement
pip install -r ComfyUI-MemoryManagement/requirements.txt
Ignore the README's "Quick Deployment" clone URL - it points at a nonexistent ComfyUI/ComfyUI-MemoryManagement repo. Use the one above.
Where people get burned
- Leak detection has a real cost. The README itself quotes 2β5% CPU and up to 100MB of memory when leak detection is active. It's the most expensive feature in the pack. Leave it on only when you're actually diagnosing a leak, or push
leak_detection_intervalway up. - This works alongside ComfyUI's memory management, not instead of it. ComfyUI already offloads models itself. What this node adds is the RAM housekeeping and the leashing of the process. Don't expect it to fix a card that's simply too small for the workflow.
- The background thread lives with the node. If you toggle the node off in the UI, management stops; if you're running multiple instances, keep one manager per session.
Common issues
- "CUDA not available" / VRAM parts silently skipped - the RAM side still works; the GPU side needs a CUDA-enabled torch.
- Memory still climbing - the README's own advice: go Aggressive, lower the thresholds (70% warning / 80% critical), and turn leak detection on long enough to see what's growing.
- Performance feels heavier than it should - raise
check_intervalto 120s and drop to Conservative. The defaults (Balanced, 45s) are reasonable, but on a machine doing heavy inference, fewer wake-ups is better.
It's the one node of the seven most people would actually want in a production workflow - if you're going to install this pack at all, start here.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| enable_smart_management | BOOLEAN | true | β |
| management_mode | COMBO | Balanced | 3 options: Conservative, Balanced, Aggressive |
| memory_warning_threshold | FLOAT | 7560β90 | β |
| memory_critical_threshold | FLOAT | 8570β95 | β |
| check_intervalopt | FLOAT | 4515β300 | β |
| enable_leak_detectionopt | BOOLEAN | true | β |
| enable_vram_optimizationopt | BOOLEAN | true | β |
| auto_cleanup_aggressiveopt | BOOLEAN | false | β |
| leak_detection_intervalopt | FLOAT | 30060β1800 | β |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| management_status | STRING | β |
| detailed_report | STRING | β |
| management_active | BOOLEAN | β |
| current_memory_usage | FLOAT | β |
| last_action | STRING | β |
| performance_stats | STRING | β |