Join GitHub today
ObserveChanges plugin causing memory leak #4400
Our Handsontable had a memory leak for some reason and couldn't work out why. Looking at the memory profile we noticed that the
Steps to reproduce
Here https://handsontable.com/blog/articles/how-to-build-a-custom-version-of-handsontable is a table with dependencies. You can check which plugins are needed to run features.
I have looked more into this issue. It seems that the issue is in the JSON patch library that is being used. The library does a comparison of two objects on two lines here and here which will always evaluate to false unless they are the exact same object reference used. Each time it evaluates to false in the
This comparison should be changed to use a different method of object comparison. One suggestion is just to stringify both objects when comparing them (i.e.
Another solution would be to manually cleanup the
EDIT: Implementing my proposed solution above seems to break a lot of tests. It seems like it should be comparing object references but there still needs to be some solution for it leaking memory. At least the cause is narrowed down to the array of Mirrors which is this line. What is the point of keeping the
Thank you for your effort, Jeremy. I am not an expert in this field but it looks like a reasonable explanation for this bug. Would it be too much to ask for a pull request?
I have asked our Support developer to take a look at this issue but he will be able to do it no sooner than on 15th of Jan.
Hello, we have found another issue with this memory leak.
We have created an api using puppeteer (Puppeteer is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome or Chromium.) which allows end users to export their tables in different formats as png/pdf.
The issue is that Chrome crashes when handsontable loads because the plugin ObserveChanges creates a big amount of listeners for huge data (above 1000 rows).
It is reproducible on linux/ubuntu machines 100%.
Just an FYI, if the handsontable has ObserveChanges: False, everything works fine.