Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Handle case where swap memory query fails on windows. (#15219)

comfyanonymousf06a187f50f8
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: