Is there a memory leak in the hello world example?
See original GitHub issueI modified the Hello World example a tiny bit to track the memory usage.
#!/usr/bin/env python3
import gc
import os
import justpy as jp
import psutil
def hello_world():
wp = jp.WebPage()
process = psutil.Process(os.getpid())
gc.collect()
wp.add(jp.Div(text=f'memory: {process.memory_info().rss:,} bytes'))
return wp
jp.justpy(hello_world)
It looks like there is a leak since the number keeps growing when reloading the page. This already happens with JustPy 0.2.x. Explicitly setting temp=True
or delete_flag=True
doesn’t help.
Weirdly, jp.WebPage.instances
are not growing. So, what else could hold the page or div objects? Or am I doing something completely wrong measuring the memory?
Issue Analytics
- State:
- Created a year ago
- Comments:9
Top Results From Across the Web
Is there a memory leak in the hello world example? · Discussion ...
I modified the Hello World example a tiny bit to track the memory usage. ... It looks like there is a leak since...
Read more >gtkmm/c++ first hello world example leaking memory
@Anton, a memory leak is memory to which you no longer have access, meaning you had a pointer to the memory, then without...
Read more >[Solved]-c++ valgrind shows memory leak in hello world-C++
Coding example for the question c++ valgrind shows memory leak in hello ... This is memory reserved forever by linux system dynamic library...
Read more >How To Detect and Prevent Memory Leaks | Scout APM Blog
Memory leak is the gradual loss of available computer memory when a program repeatedly fails to return memory it obtained for temporary use....
Read more >What is Memory Leak? How can we avoid? - GeeksforGeeks
The consequences of memory leak is that it reduces the performance of the computer by reducing the amount of available memory.
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
Ok, will check this more. This is interesting: https://github.com/tiangolo/fastapi/issues/4649 Could be a starlette issue. The dictionaries with the webpages, websockets and components are not growing. That is clear. And when you open multiple browser tabs and then close them you see that the dict entries decrease.
I’ve kept the program running for almost 25 hours now, and it looks like eventually starlette reclaims the memory. Memory usage went down from startup. I think there is no issue here to take care of.