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 usage seems high #4

Open
danyill opened this issue Nov 16, 2023 · 5 comments
Open

Memory usage seems high #4

danyill opened this issue Nov 16, 2023 · 5 comments

Comments

@danyill
Copy link

danyill commented Nov 16, 2023

I am able to get a great deal of memory usage by doing the following:

paws.zip

  1. Open the attached scd file (I think any would do).
  2. Open each editor in turn and make one change (any change) to the SCL document where possible.
  3. Wait a few seconds between each editor.
  4. Wash, rinse and repeat from left to right a few times.
  5. Monitor memory in Chrome by hovering over the tab or pressing Shift+Esc
  6. Memory usage seems to just go up and eventually the validator starts to complain about a growing buffer.

image

image

This is on Windows 10, using Chrome Version 119.0.6045.159 (Official Build) (64-bit)

I shall see if I can reproduce on Linux in some time.

It would be good to know if anyone can reproduce this issue on other browsers or other platforms.

@danyill
Copy link
Author

danyill commented Nov 17, 2023

After two rounds with the same base file on Linux I am up to 406 Mb.
With three rounds I am up to 1.4 Gb.

In each round, I open each plugin (from left to right), make one small change or switch views and move to the next plugin.

  • Ubuntu 23.10
  • Chrome Version 119.0.6045.105 (Official Build) (64-bit)

image

image

@JakobVogelsang
Copy link
Contributor

This is pointing towards the schema validator running in an extra worker. I will try and reproduce your findings.

@danyill
Copy link
Author

danyill commented Nov 18, 2023

I notice it does not happen if working in a single editor for a long time -- memory usage stays low and almost constant (92.7 Mb).

@JakobVogelsang
Copy link
Contributor

I think I know where it comes from. The validating plugin is doing a parseToString and the schema-validator a parseFromString. These artifacts are not being removed quick enough by the browser and pile up. After a while, the memory usage goes bananas.

You can check by:

  1. Disable the auto-validate and make the same changes. The memory consumption should stay the same.
  2. Just change one value, say in the Communication back and forth and see how the memory usage is rising.

Btw. I also found that the oscd-open plugin should be improved. When opening new file we are storing those is docs and never remove. When you open 10 different larger files you have easily 4 GB of usage.

@ca-d
Copy link
Contributor

ca-d commented Mar 19, 2024

After further testing, @JakobVogelsang and I noticed that a big part of the memory build-up comes just from plugins creating huge DOM trees (e.g. a list of all messages published or subscribed in the entire file) which are not garbage collected quickly enough after switching away from the editor plugin.

This is especially problematic because we currently re-render the full DOM tree every time we switch back to an editor plugin, meaning the plugin might have rendered all its content several times before a garbage collection cycle kicks in.

I propose we fix this by introducing a mechanism for keeping disabled editor plugins around in the background without updating their properties, so that they don't re-render until they become active again, and setting the inert global attribute so that a plugin can react by trimming its DOM tree while unneeded, so as to save on RAM while it's not in use.

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

No branches or pull requests

3 participants