// 1. Go to chrome://memory-redirect/ // 2. Paste this script into the developer console (function(){ var SERVER = 'http://localhost:4567/', // Post metrics to any server STRINGS = 'chrome://memory-redirect/strings.js', INTERVAL = 10e3, RE_INCLUDE = /./; // only include certain results, if you want. function getMemoryStats() { console.log('Getting stats.') xhr({ method: 'GET', url: STRINGS, callback: sendMemoryStats }) } function sendMemoryStats(req){ eval(req.responseText.replace(/loadTimeData./, '')) xhr({ method: 'POST', url: SERVER, data: formatData(data) }) } function xhr(opts){ var req, type, url, callback; method = opts.method; url = opts.url; callback = opts.callback || function(){}; data = opts.data; req = new XMLHttpRequest() req.open(method, url, true) req.onreadystatechange = function(){ if (req.readyState === 4 && req.status === 200) { callback(req) } } req.send(data) } function formatData(data){ return JSON.stringify({ browsers: data.jstemplateData.browsers.map(function(browser){ memory = getMemory(browser); memory.source = formatSource(browser.name); return memory; }), processes: data.jstemplateData.child_data .map(function(item){ memory = getMemory(item); memory.source = formatSource(item.child_name, item.titles.slice(-1)[0]); return memory; }) .filter(function(item){ return RE_INCLUDE.test(item.source) }) }); } function getMemory(measurement) { return { virtual: measurement.comm_priv * 1000, private: measurement.ws_priv * 1000 }; } function formatSource() { var args = [].slice.call(arguments); return args.join(" ") .toLowerCase() .replace(/[^a-z\- ]/g, ' ') .replace(/ [ ]*/g, ' ') .replace(/ /g, '.') .replace(/\.$/g, '') } console.info('Start collecting memory stats...') getMemoryStats() setInterval(getMemoryStats, INTERVAL) })()