#757·Eel

Memory leak: allocated data got in JS from Python is never freed.

Author: guillaume-muellerCreated Jan 10, 2025Updated Feb 14, 2025
Labelsbug

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:
python
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:
javascript
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:
xml
<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.