Skip to content
minimal monitor for JS Heap Size via performance.memory
JavaScript HTML
Branch: master
Clone or download
paulirish Merge pull request #35 from shprink/patch-1
Update Angular version link
Latest commit 6fa0f35 Jul 3, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo easier code to grok. Feb 24, 2015
README.md Update Angular version link Jul 2, 2015
bookmarklet.js bookmarklet: whitespace Feb 17, 2015
bower.json 1.0.2 Mar 5, 2015
memory-stats.js promote to its own layer. Feb 24, 2015
package.json 1.0.2 Mar 5, 2015

README.md

memory-stats.js

Like stats.js but for JS memory

@jeromeetienne, inspired by mrdoob's stats.js code, wrote this as part of tquery. I've now promoted it to a standalone repo and cleaned it all up.

image

Usage:

  1. Start Chrome with --enable-precise-memory-info
    • Otherwise the results from performance.memory are bucketed and less useful.
  2. Include memory.stats.js
  3. Instantiate it (stats = new MemoryStats(), add the stats.element to the DOM, and run stats.update() regularly.

That might look something like:

    var stats = new MemoryStats();

    stats.domElement.style.position = 'fixed';
    stats.domElement.style.right        = '0px';
    stats.domElement.style.bottom       = '0px';
    
    document.body.appendChild( stats.domElement );

    requestAnimationFrame(function rAFloop(){
        stats.update();
        requestAnimationFrame(rAFloop);
    });

Run Chrome with the flag and open demo/index.html to see it in action.

Framework adaptors

Bookmarklet

You can add this code to any page using the following bookmarklet:

javascript:(function(){var script=document.createElement('script');script.src='https://rawgit.com/paulirish/memory-stats.js/master/bookmarklet.js';document.head.appendChild(script);})()
You can’t perform that action at this time.