https://github.com/day8/office-js-memory-leak
https://github.com/day8/office-js-memory-leak
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/day8/office-js-memory-leak
- Owner: day8
- License: other
- Created: 2020-03-16T02:05:18.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-31T21:28:51.000Z (about 4 years ago)
- Last Synced: 2025-01-12T04:48:31.332Z (4 months ago)
- Language: HTML
- Homepage:
- Size: 157 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This repo provides a minimal demonstration of [office-js issue #1054](https://github.com/OfficeDev/office-js/issues/1054). It has been created using the Microsoft Yeoman office-js generator.
## To Show The Problem
1. Open a command prompt as administrator.
2. `CheckNetIsolation LoopbackExempt -a -n="microsoft.win32webviewhost_cw5n1h2txyewy"`
3. Open a command prompt as your user.
4. `git clone https://github.com/day8/office-js-memory-leak`
5. `cd office-js-memory-leak`
6. `npm install`
7. `npm start`
8. Excel should open automatically.
9. Select the 'Insert' tab in the Excel ribbon
10. Click 'My Add-ins down arrow' (the down arrow menu on the right, NOT the button on the left)
11. Under 'Developer Add-ins' click 'Content Add-in Memory Leak'
12. If you get the error "We can't open this add-in from localhost" quit Excel, run `npm stop` and go to 7.
13. If the Content Add-in loads successfully resize it so that you can see the 'Run' button.
14. Open Windows Task Manager and observe the memory use of Excel
15. Click the 'Run' button repeatedly.
16. Observe the memory usage for Excel continuing to climb each time Run is clicked.

17. After clicking the button LOTS of times, notice how memory is just contnuing to rise unbounded
18. Leave the app alone for 20 mins and notice that at some point the used memory returns to normal## Now look at the onclick handler
When you click on that `Run` button, the [`onclick`](https://github.com/day8/office-js-memory-leak/blob/master/src/contentapp/contentapp.js#L16-L24) handler is [this minimal function](https://github.com/day8/office-js-memory-leak/blob/master/src/contentapp/contentapp.js#L16-L24) which calls `Excel.run` with the simplest batch function possible.
Note: the more the batch function does with `context`, the more memory is leaked on each click of `Run`