-
-
Notifications
You must be signed in to change notification settings - Fork 605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory Leak Issue with ui.refreshable
in NiceGUI Leading to Potential risk of Service
#2502
Comments
Hi @duckgun13476,
After objects have been deleted and the garbage collector has run, Python won't release allocated memory back to the operating system. Instead it will keep it for later. Therefore it isn't sufficient to look at the memory footprint of the Python footprint to spot memory leaks. |
Have a look at discussion #1727 on how track "rough" ips which open lots of connections. |
Thank you for your response. It seems I have already found the issue. The problem lies in the Python interpreter itself not reclaiming the memory used by ng, which in turn causes the displayed data to not reflect ng's memory usage. This means that the ng server is actually reclaiming this memory, so when I access it with different IDs, the memory does not increase. This also proves that it is indeed reclaiming this data, so there is no memory leak issue. Thank you very much! |
By the way, may I ask if ng has any relevant methods or functions for detecting its own runtime memory? |
Solution:
|
Description
I've encountered a potential memory leak issue when using the
ui.refreshable
decorator in NiceGUI, which could lead to a Denial of Service (DoS) if exploited. The issue arises when running a specific code snippet that utilizes multipleui.refreshable
functions to update UI elements. In normal use, the variables update as expected across multiple connections. However, I observed a significant increase in virtual memory (approximately 20MB) when opening around 40 browser tabs, which seemed normal at first.The problem becomes apparent when these tabs are closed; the memory allocated does not seem to be released. This behavior suggests that the
ui.refreshable
decorator, along with theprune()
function, does not effectively remove the created labels, leading to persistent memory consumption.My concern is that if this behavior is exploited by creating and closing a large number of connections repeatedly, it could potentially crash the web service due to uncontrolled memory consumption.
Here is a simplified version of the code that demonstrates the issue:
Could this be a bug in the NiceGUI framework, or is there a recommended approach to ensure that memory is properly freed when using
ui.refreshable
decorators and dynamically updating UI elements?Or should I only use a single refreshable decorator?
The text was updated successfully, but these errors were encountered: