Skip to content
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: allocated data got in JS from Python is never freed. #757

Open
guillaume-mueller opened this issue Jan 10, 2025 · 0 comments
Open
Labels

Comments

@guillaume-mueller
Copy link

guillaume-mueller commented Jan 10, 2025

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:

  1. 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')
  1. 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);
    }
})();
  1. 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>
  1. Check to have 1 GB of RAM available to be allocated.
  2. Launch python main.py.
  3. Open DevTools in pressing F12.
  4. Note in the Console tab that the logged count has reached 10000, which means the data has been fully transferred.
  5. Note in the Memory tab that 1004 MB is allocated.
  6. Open OS's System Monitor (Task Manager if applicable to Windows) and note that the allocated memory for the browser process is 1.1 Go.
  7. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant