Memory leak on linux inside Docker for a trivial ui
See original GitHub issueSpecification
- Platform: linux (inside docker container)
- Version: 2.1
Description
After running a very simple UI for few minutes, memory grows to hundreds of MB (and GB after longer period of time). It’s basically enough call the api from javascript in a loop. I’m attaching python code (with requirements.txt), html and dockerfile for reproduction.
NOTE: I haven’t seen this problem on the newest version (2.2.1), but as it has different system requirements (uses webkit2) we can’t update.
ui.py:
import threading
import webview
class Api:
def getStatus(self, params):
return None
def read_file(file):
with open(file, "r", encoding="utf-8") as f:
return f.read()
def read_html():
return read_file("index.html")
def create_app():
webview.load_html(read_html())
def main():
t = threading.Thread(target=create_app)
t.start()
api = Api()
webview.create_window("UI", js_api=api)
t.join()
if __name__ == "__main__":
main()
index.html:
<!DOCTYPE html>
<html>
<body id="body">
<scrilpt>
function checkMagicLoaderStatus() {
pywebview.api.getStatus();
}
window.setInterval(checkMagicLoaderStatus, 20);
</scrilpt>
</body>
</html>
requirements.txt:
requests==2.19.1
PyGObject==3.30.1
pywebview==2.1
pytest==3.8.1
pyrsistent==0.14.4
Dockerfile:
FROM python:3.7.0
WORKDIR /usr/src/app
RUN apt-get update
RUN apt-get install -y libgirepository1.0-dev gir1.2-webkit-3.0 libcanberra-gtk-module libcanberra-gtk3-module
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# suppress GTK warnings about accessibility because there's no dbus
ENV NO_AT_BRIDGE 1
COPY . .
CMD [ "python", "./ui.py" ]
Commands to build and run:
docker -- build . -t ${DOCKER_IMAGE}:${DOCKER_TAG}
docker run -it -e DISPLAY -v $XAUTHORITY:/root/.Xauthority --net=host ${DOCKER_IMAGE}:${DOCKER_TAG}
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Debugging Memory Leaks in a Containerised Node Application
Find out how to debug memory leaks in a Docker-based React/Node app, using Prometheus, Grafana, Chrome's Node inspector and Locust.
Read more >Memory Leak on ridiculously simple repo · Issue #7874 - GitHub
Running many test files causes a memory leak. I created a stupid simple repo with only Jest installed and 40 tautological test files....
Read more >9. Finding Memory Leaks - VisIt User Manual
We support several mechanisms to find memory leaks. The two best mechanisms are using Valgrind and vtkDebugLeaks. Valgrind is used to detect memory...
Read more >Docker daemon memory leak due to logs from long running ...
Docker daemon memory leak has been talked about in this issue and this issue. But both of them are closed now saying merged...
Read more >Debugging RAM: Detect/Fix Memory Leaks in Managed ...
In this article, I'll walk you through debugging memory usage. ... This is an interesting native tool to debug memory leaks in Linux...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For the record, I believe the source of the leak is this code:
It creates a new variable with a unique name each time. The fix would be to delete window.oldTitle{0} after use.
@kgrygiel You are indeed correct. As newer version does not seem to have this memory leak and backporting webkit 1 is likely not to happen anytime soon, I am closing this PR. It is good to have a solution documented though.