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 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-allocation-profiler

v1.0.0

Published

A command line tool for profiling Node.js memory allocations using Chrome DevTools Protocol

Downloads

1

Readme

Node.js Allocation Profiler

A command line tool for profiling Node.js memory allocations using Chrome DevTools Protocol. This tool helps you understand memory allocation patterns in your Node.js applications by tracking heap allocations and providing detailed analysis.

Features

  • Heap Allocation Tracking: Uses Chrome DevTools Protocol to track memory allocations
  • Function-level Analysis: Analyze allocations by function name patterns
  • Tree Structure Visualization: View detailed allocation trees with function information
  • Flexible Output: Save heaptimeline files or just view summaries
  • Pattern Matching: Use regex patterns to focus on specific functions

Installation

Global Installation (Recommended)

npm install -g node-allocation-profiler

Local Installation

npm install node-allocation-profiler

Then use with npx:

npx node-allocation-profiler <target.js>

Usage

Basic Usage

node-allocation-profiler <target.js>

This will profile the target script and show allocation summaries for functions matching the default pattern ^benchmark.

Command Line Options

  • --save-heaptimeline[=filename] - Save heaptimeline file (generates filename if not specified)
  • --function-pattern=pattern - Regex pattern to match function names (default: /^benchmark/)
  • --print-tree - Print the full allocation tree structure
  • --help, -h - Show help message
  • --version, -v - Show version information

Examples

Profile a script with default settings

node-allocation-profiler my-script.js

Save heaptimeline file with auto-generated filename

node-allocation-profiler my-script.js --save-heaptimeline

Save heaptimeline file with custom filename

node-allocation-profiler my-script.js --save-heaptimeline=my-profile.heaptimeline

Profile functions matching a specific pattern

node-allocation-profiler my-script.js --function-pattern="^test"

Show full allocation tree for all functions

node-allocation-profiler my-script.js --function-pattern=".*" --print-tree

Profile benchmark functions with detailed tree view

node-allocation-profiler my-script.js --print-tree

How It Works

  1. Process Launch: The tool launches your target script with Node.js inspector enabled
  2. Allocation Tracking: Enables heap allocation tracking via Chrome DevTools Protocol
  3. Execution: Resumes script execution and waits for completion
  4. Snapshot: Takes a heap snapshot when the script finishes
  5. Analysis: Parses the snapshot and analyzes allocation patterns
  6. Output: Displays results based on your specified options

Target Script Requirements

Your target script should:

  1. Signal Completion: Output __PROFILE_DONE__ to stderr when finished
  2. Be Profilable: Work with Node.js inspector (most scripts do)

Example target script:

// Your profiling target
function benchmark() {
  // Your code here
}

benchmark();
console.error('__PROFILE_DONE__');

Output Format

The tool provides:

  • Function Information: Name, script location, line/column numbers
  • Allocation Metrics: Count and size of allocations
  • Per-iteration Stats: Normalized metrics (assuming 10k iterations)
  • Tree Structure: Hierarchical view of allocation calls (when --print-tree is used)

File Structure

node-allocation-profiler/
├── bin/
│   └── node-allocation-profiler.js    # Command line interface
├── lib/
│   ├── allocation-profile.js           # Profile parsing logic
│   ├── analyzer.js                     # Analysis and output formatting
│   ├── profiler.js                     # Chrome DevTools Protocol integration
│   ├── utils.js                        # Utility functions
│   └── index.js                        # Main exports
├── package.json
└── README.md

Dependencies

  • chrome-remote-interface - Chrome DevTools Protocol client
  • Node.js 16+ (for ES modules support)

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.