Skip to content

Instantly share code, notes, and snippets.

@jvandyke
Last active August 29, 2015 14:14
Show Gist options
  • Save jvandyke/e83ccdc4387a7ddc771f to your computer and use it in GitHub Desktop.
Save jvandyke/e83ccdc4387a7ddc771f to your computer and use it in GitHub Desktop.
Show continuous memory profile for JavaScript application
Copied from https://github.com/paulirish/memory-stats.js
## memory-stats.js
Like [stats.js](https://github.com/mrdoob/stats.js/) but for JS memory
[@jeromeetienne](https://github.com/jeromeetienne/), inspired by mrdoob's stats.js code, wrote this as part of [tquery](https://github.com/jeromeetienne/tquery). I've now promoted it to a standalone repo and cleaned it all up.
![image](http://i.imgur.com/eUCFcAH.gif)
### Usage:
1. Start Chrome with `--enable-precise-memory-info`
- Otherwise the results from performance.memory are bucketed and less useful.
1. Include memory.stats.js
1. Instatiate it (`stats = new MemoryStats()`, add the `stats.element` to the DOM, and run `stats.update()` regularly.
That might look something like index.html.
<script src="https://cdn.rawgit.com/paulirish/memory-stats.js/master/memory-stats.js"></script>
<script>
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);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment