This node releases any memory currently used by ComfyUI and the underlying framework that is not expressly necessary. It does so by requesting garbage collection from several different sources, including ComfyUI itself, Torch and Python's Garbage Collector.
Use this node to run workflows that are triggering Out of Memory errors due to RAM exhaustion. It may just be enough to let you run a workflow that would otherwise give you errors and not complete. If your issue stems from a lack of VRAM instead, try this node in conjunction with the [Unload Models] node, immediately after it.
The Input and Outputs of this node are a simple passthrough that will forward any data sent through this node, after garbage collection has completed.
IF RAM cleaning is enabled, the node will additionally call WinMemoryCleaner.exe to flush memory from Windows and release unused pages from memory. In order for this functionality to work, WinMemoryCleaner.exe must be downloaded from its respective Github (https://github.com/IgorMundstein/WinMemoryCleaner) and placed within the root ComfyUI folder.
If Mode is set to Run_Async, WinMemoryCleaner.exe will be executed and the workflow execution will continue automatically. This however requires ComfyUI (or rather Python specifically) to be running with Administrative privileges. Otherwise you can use the 'Wait until Completion' mode which does not require administrative privileges and will block execution for a few seconds and resume when the RAM has been thoroughly cleaned and released.
HOVER OVER THE INPUTS AND OUTPUTS FOR MORE INFO.
By VykosXΒ·Created 2 years agoΒ·Updated 2 years agoΒ· 147
π Garbage Collector
Input
Output
βRAMtrueβΊ
βModefalseβΊ
CategoryπΊ VykosX-ControlFlowUtils
Inputs (3)
Name
Type
Default
Description
Input
*
Data to forward to other nodes after cleaning the memory
RAM
BOOLEAN
true
Attempt to clear the RAM on Windows systems. Requires WinMemoryCleaner.exe to be placed in the ComfyUI root folder
Mode
BOOLEAN
false
Specifies whether to wait for memory cleaning to succeed before continuing
Outputs (1)
Name
Type
Description
Output
*
Data that will be forwarded to other nodes after cleaning the memory