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 is very incorrect on some projects #250

Closed
NathanaelA opened this issue Nov 23, 2022 · 1 comment · Fixed by #352
Closed

Memory usage is very incorrect on some projects #250

NathanaelA opened this issue Nov 23, 2022 · 1 comment · Fixed by #352

Comments

@NathanaelA
Copy link

NathanaelA commented Nov 23, 2022

Some projects use the system webview, when they allocate and use the system webivew the memory is allocated by the system and so it shows up as being used by the system. It unfortunately is not actually tracked against the process. This gives you a very invalid idea of how much memory the actual process is actually using...

For example, Wails (or Tauri) might just 40m memory usage, but the system might be using another 60m of memory for the webview instance that it is managing on behalf of the Tauri/Wails app. To get the actual memory usage of these types of projects, you need to measure total system memory usage before app is ran, and then while app is being ran to see how much memory the system had to allocate for the process. Doing this either multiple times in a row or running the app multiple times at the same time can give you the approximate memory usage the system is allocating for each run of app that is using a system webview. (Please note, when checking global memory you will also need to check for additional used swap memory usage, and ignore any memory used or freed by caches)

In my tests, the majority of the memory is NOT shared between instances and is allocated per instance of the app. Even though the system is allocating the memory, it is purely for the app and is not actually shared.


One other very minor nitpick, the html used in each app (for those using a webview) should be as close to identical as possible. For example if I do <div>This is Electron</div> and do <div><p><b>This is NW.JS</b></p></div> the memory NW.JS uses in the webview will be more than Electron, because you now have three HTMLNodes having to be allocated by the webview in NW.JS vs the one in Electron. So to make things a lot closer, I would recommend that at least for your base tests, that the html displayed is as close to identical as possible to eliminate any extra css or html that has to be rendered, processed and allocated... 😀

@Elanis
Copy link
Owner

Elanis commented Nov 24, 2022

Hi !

Very good remarks !

Thanks for you ideas :) I'm gonna improve benchmark that way when I get some time !
(Or if anyone wants to try, they can too 😄)

For the first point, I was unsure Webview2 (for example) would be embed in the sum, but your idea looks neat, I'm definitely gonna try to see if that gaves great results.
For the second point, I'm already trying to make as close examples as possible, e.g. I removed most of the start time timer code and made it external, to prevent differences caused by that function. But looking at HTML structure is a great idea as well !

Elanis added a commit that referenced this issue Dec 20, 2022
Elanis added a commit that referenced this issue Dec 22, 2022
- Closes #14 - Minification of tauri build
- Update nw.js from 0.70.1 to 0.71.0
- Closes #26 - Add informations about automated tests
- Closes #140 - Add informations about auto-updater
- WIP #250 - Make pages more equal by having an alike html source, and no css
- Closes #46 - Add wails benchmark
@Elanis Elanis pinned this issue Jan 17, 2023
@Elanis Elanis linked a pull request Feb 8, 2023 that will close this issue
Elanis added a commit that referenced this issue Jul 31, 2023
* #250 - Add another way to measure used memory
* #252 - Count additional files size
* Fix system memory usage storage when persisting data
* Upgrade to node18 
NodeGUI/qode now support it: https://github.com/nodegui/nodegui/releases/tag/v0.58.0
* Fix median value calculation
* Force garbage collection to make results more accurate
* Improvements in memory calculation
* Improve logging
* Use tree-kill instead of custom function to try terminating all process without issues
* Update benchmarks
@Elanis Elanis unpinned this issue Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants