python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.41k stars 586 forks source link

Memory leak on JavaScript side. #666

Closed luki009 closed 1 year ago

luki009 commented 1 year ago

Eel version Eel 0.15.3

Describe the bug Looks like major memory issue on JavaScript side. Looks like this is not related to reported bug on python side memory leak. Seems that every call of exposed JS function from python side causes increase of memory heap until it crashes Chrome browser.

performance.memory MemoryInfo {totalJSHeapSize: 124998479, usedJSHeapSize: 120135399, jsHeapSizeLimit: 4294705152}

HeapSize will not stop increasing even after python calls stops . Speed of increasing is exponentional to number of python requests made. I was not able to find out exactly what is causing this issue but I have suspicion that it is related to some Timer which is created after exposed JS function is called from python. In my case Total JS Heap size will rise to limit of 4GB in less then 15 mins after 100 requests are made. memory heap will reset after page reload and stays low until again new requests are made so definitely something what is attached to window/DOM element. Note: Value is returned to python as expected and action on JS side is executed as expected without issues.

To Reproduce Steps to reproduce the behavior:

  1. Make series of callings to exposed js function from python
  2. if Chrome used open developer tools F12 and go to Memory tab
  3. Watch how Total JS Heap Size is increasing until browser crashes with err msg: Out of Memory

Expected behavior Expectation is that Timers or callbacks will not hang after exposed function is executed.

System Information

Screenshots image

JS Heap increasing after python calls stopped image image

Heap Size is always increasing in timer call image

Additional context Only reference to Timer in eel.js which might be related. _sleep: function(ms) { return new Promise(resolve => setTimeout(resolve, ms)); },

It is clear that new and new timers are set and garbage collector it not really able to manage it.

luki009 commented 1 year ago

Please ignore this report. After spending another night with debugging I finally found that memory leak is not caused by eel JavaScript. It is true that JS heap starts increasing after calls from python but in my case there was 1 call in beginning to jquery.toast to display start message which will cause memory leak.

So for everyone be careful with jQuery.toast