npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

heapsnapshot-parser

v0.1.0

Published

Parses heapsnapshot files from node.js and Chrome V8.

Downloads

75

Readme

Parses heapsnapshot files from node.js and Chrome V8.

Install

npm install --save heapsnapshot-parser

Usage

var fs = require('fs');
var parser = require('heapsnapshot-parser');

var snapshotFile = fs.readFileSync(filename, {encoding: "utf-8"});
var snapshot = parser.parse(snapshotFile);

for (var i = 0; i < snapshot.nodes.length; i++) {
    var node = snapshot.nodes[i];
    console.log(node.toShortString());
}

API

parse(snapshot, options)

Returns a new HeapSnapshot object.

If options.reporter() is provided, reporter({message}) will be called throughout the parsing process to indicate progress.

Snapshot

The snapshot returned from parse() has the following properties:

  • nodes - an array of Node objects, one for every object found in the heap snapshot.
  • nodesById - a hash of Node objects, indexed by their ID.
  • edges - an array of Edge objects, one for every edge found in the heap snapshot.

Node

All properties from the node present in the heapsnapshot file are copied directly to the Node object. This includes:

  • type - (string) The type of the object.
  • name - (string) The name of the object.
  • id - (integer) A unique numeric ID for the object.
  • self_size - (integer) Size of the object in bytes, not including any referenced objects.
  • trace_node_id - ???

In addition, each node has the following properties:

  • references - An array of Edge objects for nodes which this node references.
  • referrers - An array of Edge objects for nodes which reference this object.

Node.getProperty(name, edgeType='property')

If this Node has a reference to another Node of the specified name and edgeType, returns the Node. Returns null otherwise.

Node.toString()

Returns a string representation of this node.

Node.toShortString()

Returns a one-line string representation of this node.

Edge

All properties from the edge present in the heapsnapshot file (except to_node) are copied directly to the Edge object. This includes:

  • type - (string) The type of the edge.
  • name_or_index - (string) The name (or index, for an array element) for this edge.

In addition, each node has the following properties:

  • fromNode, toNode - Node objects for the referring and referred object for this edge.

Edge.toString()

Returns a string representation of this edge.

TODO

Suggested Reading

Some articles about how objects are represented in V8: