ComfyUI-MacMemoryMonitor
Real-time memory monitor for ComfyUI on Apple Silicon (MPS / unified memory) — unified RAM, MPS driver/active, MLX Metal, swap, and per-run peaks. The Mac analogue of ComfyUI-MemoryVisualization.
ComfyUI-MacMemoryMonitor
A real-time memory monitor for ComfyUI on Apple Silicon (MPS / unified memory).
It's the Mac analogue of kijai/ComfyUI-MemoryVisualization, but rewritten for the unified-memory model: a Mac has no separate VRAM pool — the GPU and CPU share one memory bank — so this reports unified RAM + the MPS allocator's view of it, instead of "VRAM vs RAM".
What it shows
A small floating panel (top-left by default, draggable, collapsible):
| Bar | Source |
|-----|--------|
| Unified RAM used / total | psutil.virtual_memory() |
| MPS driver allocated, vs the recommended-max "budget" | torch.mps.driver_allocated_memory() / torch.mps.recommended_max_memory() |
| MPS active (currently allocated tensors) | torch.mps.current_allocated_memory() |
| MLX Metal (active + cache), vs budget — populated by the Mac Memory Probe node | mlx.core.get_active_memory() + get_cache_memory() |
| Swap used / total | psutil.swap_memory() |
| Meta line: CPU %, ComfyUI process RSS, MLX cache, MPS budget | psutil + torch + mlx |
| Loaded models list with sizes + device | comfy.model_management.current_loaded_models |
Why the MLX bar matters: MLX-based nodes (e.g. mflux) allocate Metal memory directly, bypassing PyTorch — so
torch.mpsreports it as ~0 and ComfyUI's model manager shows "no models loaded" even while gigabytes are in use. The MLX Metal bar surfaces that hidden memory, and the MLX cache figure is the part that accumulates across repeated runs (a common cause of out-of-memory crashes on unified-memory Macs).Thread-safety note: MLX uses per-thread GPU streams, so its memory functions must only be called from the ComfyUI execution thread — calling them from the web-server thread can throw
There is no Stream(gpu, 0) in current thread, an uncatchable abort. So MLX figures are captured by the Mac Memory Probe node (which runs on the execution thread) and the panel shows the most recent snapshot; the HTTP route never calls MLX directly. Add a probe node to your graph to populate the MLX bar.
During a run the title shows a green ● and a yellow peak marker tracks the high-water mark for Unified RAM, MPS-driver, and MLX memory (reset at each run start).
Two ways to use it
- Floating panel — appears automatically. Toggle it from the ComfyUI settings (⚙) → "Mac Memory Monitor: show panel", or the ✕ on the panel.
Mac Memory Probenode (utils/memorycategory) — a pass-through you can wire inline on any connection (image, latent, model, …). When it executes it prints a memory snapshot to the console and shows it on the node, so you can see usage at an exact point in the graph (e.g. right after the sampler, before VAE decode). It passes its input straight through, plus areportstring output.
How it works
__init__.pyregisters an aiohttp GET route/macmem/statson ComfyUI's server that returns all the figures above as JSON, and theMacMemProbenode.web/mac_mem_monitor.jsregisters a ComfyUI extension that polls that route every 500 ms and draws the DOM panel; it listens toexecution_start/execution_successAPI events to drive the run indicator and peak reset.
No canvas, no themes, no CUDA/NVML dependencies — intentionally minimal.
Example workflow
example_workflows/mflux_anymodel_memory_monitor.json — a text-to-image run using
the mflux Model Loader (MLX) → mflux Sampler (MLX) nodes
(from comfyui-mflux-anymodel) with a Mac Memory Probe wired onto the image
output, feeding a Preview. It includes a How-to-use note node on the canvas.
Load it via ComfyUI's Workflow → Open (or drag the .json onto the canvas),
make sure the floating panel is visible, then Queue Prompt and watch memory
climb during the run. Requires the comfyui-mflux-anymodel nodes to be installed
(they are, in this ComfyUI).
Install
cd ComfyUI/custom_nodes
git clone https://github.com/stratopause-lsc/ComfyUI-MacMemoryMonitor
Then restart ComfyUI. No extra dependencies beyond what ComfyUI already ships
(torch, psutil).
- Browser: hard-refresh with ⌘⇧R after installing/updating.
- ComfyUI Desktop app: the webview caches extension files aggressively — after installing or updating, do a hard reload (⌘⇧R) or fully quit and reopen, or the panel can render with stale/unstyled assets.
Notes / limits
torch.mps.*figures reflect PyTorch's MPS allocator only. Other GPU users on the system (other apps, other processes) aren't attributed — for the true whole-machine picture use the Unified RAM bar, which is system-wide.- macOS has no per-process GPU-memory API as clean as NVML; there's deliberately no "GPU utilization %" or temperature/power readout like the CUDA original.
Credits
Architecture inspired by kijai/ComfyUI-MemoryVisualization (the NVIDIA/VRAM equivalent). This project shares no code with it — the entire Python backend and JavaScript frontend were written from scratch for Apple Silicon / MPS unified memory. Thanks to kijai for the original idea.
License
MIT — see LICENSE.