Eel
Eel copied to clipboard
Memory leak: allocated data got in JS from Python is never freed.
Eel version v0.18.1
Describe the bug The memory allocated by JavaScript for the data received from a Python Eel-exposed function is never freed.
To Reproduce Steps to reproduce the behavior:
- Create
main.py:
import eel
count = 0
data = 'x' * 100_000 # 100 KB
@eel.expose
def get_data():
global count
count += 1
return {
'count': count,
'data': data
}
eel.init('.')
eel.start('main.html')
- Create
main.js:
amount_of_iterations = 10_000; // 1GB
(async () => {
for (let i = 0; i < amount_of_iterations; i++) {
const data = await eel.get_data()();
console.log(data.count);
}
})();
- Create
main.html:
<html>
<head>
<script type="text/javascript" src="eel.js"></script>
<script type="text/javascript" src="main.js"></script>
</head>
<body>Check DevTools (F12).</body>
</html>
- Check to have 1 GB of RAM available to be allocated.
- Launch
python main.py. - Open
DevToolsin pressing F12. - Note in the
Consoletab that the logged count has reached 10000, which means the data has been fully transferred. - Note in the
Memorytab that 1004 MB is allocated. - Open OS's
System Monitor(Task Managerif applicable to Windows) and note that the allocated memory for the browser process is 1.1 Go. - Wait as long as you want but maybe at least 1 minute and note that nothing has changed.
Expected behavior The allocated memory should be freed at some point.
System Information
- OS: Linux Mint 22 Cinnamon (based on Ubuntu 24.04)
- Browser: Chromium 131.0.6778.204 (Official build) for Linux Mint (64 bits)
- Python Distribution: Python.org 3.12.3
Additional context I discovered this issue because I need to continuously stream data over time to a plot. At some point it makes the app crash, which can be reproduced in the example provided in increasing the allocated memory.