mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 11:07:55 -05:00
After a burst of file uploads and long chats, the process kept most of the memory it needed at the peak, and every further burst added more. On Linux with glibc, blocks of 1 MB and larger now go back to the system as soon as they are freed, which stops the growth, and every 30 seconds the freed memory glibc still holds is returned too, which brings the level down further. `MALLOC_RELEASE_THRESHOLD` sets that size in bytes and `MALLOC_TRIM_INTERVAL` that interval in seconds, and `0` turns either one off. While the threshold is on, it overrides glibc's own `MALLOC_MMAP_THRESHOLD_` and `MALLOC_TRIM_THRESHOLD_`. The median request took about 9% longer on this upload-heavy load (9.8 s to 10.7 s) with both on. 900 chats with a file upload each, in six bursts of 150. The process sat at 1.18 GB before the load in every run. <table> <tr><th></th><th>Memory after the load</th></tr> <tr><td>Without the change</td><td>4.47 GB, still climbing</td></tr> <tr><td>Immediate release only</td><td>1.95 GB</td></tr> <tr><td>Periodic release only</td><td>4.26 GB, still climbing</td></tr> <tr><td>Both</td><td>1.52 GB, flat</td></tr> </table> Fixes #35590