memory-stats.js

minimal monitor for JS Heap Size via performance.memory

Github stars Tracking Chart

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);})()

Main metrics

Overview
Name With Ownerpaulirish/memory-stats.js
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 2)
Platform
License:
所有者活动
Created At2015-01-21 06:34:33
Pushed At2015-07-03 19:31:33
Last Commit At2015-07-03 12:31:33
Release Count0
用户参与
Stargazers Count2.1k
Watchers Count50
Fork Count106
Commits Count71
Has Issues Enabled
Issues Count12
Issue Open Count3
Pull Requests Count17
Pull Requests Open Count0
Pull Requests Close Count9
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private