feat(model-manager): "Free GPU memory" button to unload ComfyUI models

ComfyUI caches the last model when RAM is plentiful (unified memory), so
memory doesn't drop after switching models even though models are being
swapped, not accumulated. Add a sidebar "Free GPU memory" button that
proxies ComfyUI's POST /free (unload_models + free_memory) via a new
/api/comfyui/free endpoint (COMFYUI_URL env). Verified it releases ~7GB.
README documents this plus the --disable-smart-memory auto-unload option.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 17:14:37 -04:00
parent c2b0f202bf
commit 399acabd58
7 changed files with 53 additions and 1 deletions
+18
View File
@@ -663,6 +663,24 @@ $("#saveSettings").addEventListener("click", async () => {
}
});
// ---- free GPU memory ------------------------------------------------------
$("#freeMemBtn").addEventListener("click", async () => {
const btn = $("#freeMemBtn");
const msg = $("#freeMemMsg");
btn.disabled = true;
msg.className = "form-msg"; msg.textContent = "Unloading…";
try {
await api("/api/comfyui/free", { method: "POST" });
msg.className = "form-msg ok"; msg.textContent = "Models unloaded.";
} catch (err) {
msg.className = "form-msg err"; msg.textContent = err.message;
} finally {
btn.disabled = false;
setTimeout(() => { msg.textContent = ""; }, 4000);
}
});
// ---- boot -----------------------------------------------------------------
(async function init() {
+6 -1
View File
@@ -33,7 +33,12 @@
<span class="nav-ico"></span> Settings
</button>
</nav>
<div class="sidebar-foot" id="modelsDir"></div>
<div class="sidebar-foot">
<button class="btn" id="freeMemBtn" title="Unload all models from ComfyUI and free GPU/RAM">
⏏ Free GPU memory
</button>
<span class="form-msg" id="freeMemMsg"></span>
</div>
</aside>
<main class="content">
+3
View File
@@ -58,7 +58,10 @@ nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar-foot {
margin-top: auto; color: var(--text-dim); font-size: 11px;
word-break: break-all; padding: 8px 6px 0;
display: flex; flex-direction: column; gap: 6px;
}
.sidebar-foot .btn { width: 100%; font-size: 13px; }
.sidebar-foot .form-msg { font-size: 11px; text-align: center; }
/* ---- content ---- */
.content { flex: 1; overflow-y: auto; padding: 26px 32px; }