diff --git a/comfy/model_management.py b/comfy/model_management.py index 11683a90..77c05510 100644 --- a/comfy/model_management.py +++ b/comfy/model_management.py @@ -426,7 +426,7 @@ def free_memory(memory_required, device, keep_loaded=[]): shift_model = current_loaded_models[i] if shift_model.device == device: if shift_model not in keep_loaded: - can_unload.append((sys.getrefcount(shift_model.model), shift_model.model_memory(), i)) + can_unload.append((-shift_model.model_offloaded_memory(), sys.getrefcount(shift_model.model), shift_model.model_memory(), i)) shift_model.currently_used = False for x in sorted(can_unload):