diff --git a/__init__.py b/__init__.py index af1c31e..732a80a 100644 --- a/__init__.py +++ b/__init__.py @@ -2,10 +2,7 @@ import psutil import ctypes from ctypes import wintypes import time -import os import platform -import subprocess -import tempfile import gc from server import PromptServer import comfy.model_management @@ -117,8 +114,8 @@ class RAMCleanup: if system == "Windows": ctypes.windll.kernel32.SetSystemFileCacheSize(-1, -1, 0) elif system == "Linux": - subprocess.run(["sudo", "sh", "-c", "echo 3 > /proc/sys/vm/drop_caches"], - check=False, stderr=subprocess.PIPE, stdout=subprocess.PIPE) + libc = ctypes.CDLL("libc.so.6") + libc.malloc_trim(0) except: pass @@ -140,8 +137,6 @@ class RAMCleanup: try: if system == "Windows": ctypes.windll.kernel32.SetProcessWorkingSetSize(-1, -1, -1) - elif system == "Linux": - subprocess.run(["sync"], check=True) except: pass diff --git a/pyproject.toml b/pyproject.toml index a6dd0a5..f46ffdd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui_memory_cleanup" description = "A ComfyUI extension that provides nodes for memory cleanup, including VRAM and RAM cleanup functions to optimize ComfyUI performance during long running workflows." -version = "1.1.2" +version = "1.1.3" dependencies = ["psutil"] [project.urls]