From f06a187f50f896e4a0ba5be1ce1f2d2dcd13b77b Mon Sep 17 00:00:00 2001 From: comfyanonymous <121283862+comfyanonymous@users.noreply.github.com> Date: Sat, 1 Aug 2026 22:12:12 -0700 Subject: [PATCH] Handle case where swap memory query fails on windows. (#15219) --- comfy/model_management.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/comfy/model_management.py b/comfy/model_management.py index f7351224d..e3c94c15a 100644 --- a/comfy/model_management.py +++ b/comfy/model_management.py @@ -684,7 +684,11 @@ def should_free_pins_for_ram_pressure(shortfall): return True if psutil.virtual_memory().available < WINDOWS_PIN_EVICTION_EMERGENCY_AVAILABLE: return True - return psutil.swap_memory().percent >= WINDOWS_PIN_EVICTION_SWAP_PERCENT + try: + return psutil.swap_memory().percent >= WINDOWS_PIN_EVICTION_SWAP_PERCENT + except RuntimeError as err: + logging.warning("Could not read Windows swap usage; falling back to RAM-pressure pin eviction: %s", err) + return True def ensure_pin_budget(size, evict_active=False, loaded=False): if args.high_ram: