Programmatically get memory usage in Chrome

倖福魔咒の 提交于 2019-11-28 07:22:22

For anyone that finds this in the future, since version 20 Chrome supports window.performance.memory, which returns something like:

{
  totalJSHeapSize: 21700000,
  usedJSHeapSize: 13400000,
  jsHeapSizeLimit: 1620000000
}

An alternative approach: write a web page scraper pointing to this URL:

chrome://system/

(note: in case this URL changes again, this is the 'master' URL that lists all the chrome diagnostic pages: chrome://chrome-urls/

the page has a section 'mem_usage' that gives details of memory usage.

maybe there is some way to script Chrome as a user (say in AutoIT or Python?) that loads this URL in Chrome, and then presses the Update button, and then parses the JSON to get the memory usage for whatever tabs you are interested in.


OTHER approaches:

  • from JavaScript - use window.performance

  • from JavaScript - use browser-report.js -

https://www.npmjs.com/package/browser-report

The chrome dev channel has a process api, chrome.process. You can query it for a tab's process information, which includes all kinds of memory information. http://developer.chrome.com/extensions/processes.html

There is a js library for that: https://github.com/spite/memory-stats.js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!