Merge pull request #5413 from electron/process-resource-usage

Fetch Process resource usage from WebContents
This commit is contained in:
Cheng Zhao 2016-05-14 23:28:51 +09:00
commit 5ec2e8d7e5
6 changed files with 114 additions and 8 deletions

View file

@ -106,4 +106,43 @@ In the browser window some HTML APIs like `requestFullScreen` can only be
invoked by a gesture from the user. Setting `userGesture` to `true` will remove
this limitation.
### `webFrame.getResourceUsage()`
Returns an object describing usage information of Blink's internal memory
caches.
```javascript
console.log(webFrame.getResourceUsage())
```
This will generate:
```javascript
{
images: {
count: 22,
size: 2549,
liveSize: 2542,
decodedSize: 478,
purgedSize: 0,
purgeableSize: 0
},
cssStyleSheets: { /* same with "images" */ },
xslStyleSheets: { /* same with "images" */ },
fonts: { /* same with "images" */ },
other: { /* same with "images" */ },
}
```
### `webFrame.clearCache()`
Attempts to free memory that is no longer being used (like images from a
previous navigation).
Note that blindly calling this method probably makes Electron slower since it
will have to refill these emptied caches, you should only call it if an event
in your app has occured that makes you think your page is actually using less
memory (i.e. you have navigated from a super heavy page to a mostly empty one,
and intend to stay there).
[spellchecker]: https://github.com/atom/node-spellchecker