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

@matteodisabatino/gc_info

v2.1.0

Published

Exposes node v8 garbage collection stats

Downloads

1,850

Readme

gc_info

Gives you information about V8 GC after its execution. Based on gc-stats.

Since version 1.0.0 the module supports all existing Node.js versions since 0.8 to the current release and binaries for Node.js 5+ are provided together; for prior versions module must be compiled.

Since version 1.2.0 the module supports all existing Electron versions since 0.3.1 to the current release and binaries for Electron 0.36.0+ are provided together; for prior versions module must be compiled.

Since version 2.0.0 the module provides binaries only for Node 17+ and Electron 23+; for prior versions module must be compiled.

It is a C++ addon written using the module nan and following the Google C++ Style Guide except for the lint. If you find something not compliant with, please provide a pull request.

In general every pull request that will:

  • Let the code be compliant to Google C++ Style Guide
  • Improve performances
  • Save memory
  • Add features

are well accepted.

Usage

Require the module and subscribe the data event.

Basic

const gcInfo = require('@matteodisabatino/gc_info')

gcInfo.on('data', info => {
  console.log('GC information: ', info)
})

Unsubscribe specific listener

const gcInfo = require('@matteodisabatino/gc_info')

const listener1 = info => {
  console.log('listener1 - GC information: ', info)
}

const listener2 = info => {
  console.log('listener2 - GC information: ', info)
}

gcInfo.on('data', listener1)
gcInfo.on('data', listener2)

gcInfo.off('data', listener1) // listener1 is no longer active but
                              // you will still receive data via
                              // listener2.

Unsubscribe all listeners

const gcInfo = require('@matteodisabatino/gc_info')

const listener1 = info => {
  console.log('listener1 - GC information: ', info)
}

const listener2 = info => {
  console.log('listener2 - GC information: ', info)
}

gcInfo.on('data', listener1)
gcInfo.on('data', listener2)

gcInfo.off('data') // Both listener1 and listener2 are no longer
                   // active. You will not receive any data until you
                   // will subscribe the `data` event again.

Information

{
  startedAt: Number,
  endedAt: Number,
  duration: Number,
  gctype: Number,
  pre: {
    totalHeapSize: Number,
    totalHeapSizeExecutable: Number,
    usedHeapSize: Number,
    heapSizeLimit: Number,
    totalPhysicalSize: Number,
    totalAvailableSize: Number,
    mallocedMemory: Number,
    peakMallocedMemory: Number,
    numberOfNativeContexts: Number,
    numberOfDetachedContexts: Number,
    externalMemory: Number,
    totalGlobalHandlesSize: Number,
    usedGlobalHandlesSize: Number
  },
  post: {
    totalHeapSize: Number,
    totalHeapSizeExecutable: Number,
    usedHeapSize: Number,
    heapSizeLimit: Number,
    totalPhysicalSize: Number,
    totalAvailableSize: Number,
    mallocedMemory: Number,
    peakMallocedMemory: Number,
    numberOfNativeContexts: Number,
    numberOfDetachedContexts: Number,
    externalMemory: Number,
    totalGlobalHandlesSize: Number,
    usedGlobalHandlesSize: Number
  },
  diff: {
    totalHeapSize: Number,
    totalHeapSizeExecutable: Number,
    usedHeapSize: Number,
    heapSizeLimit: Number,
    totalPhysicalSize: Number,
    totalAvailableSize: Number,
    mallocedMemory: Number,
    peakMallocedMemory: Number,
    numberOfNativeContexts: Number,
    numberOfDetachedContexts: Number,
    externalMemory: Number,
    totalGlobalHandlesSize: Number,
    usedGlobalHandlesSize: Number
  }
}

Property meaning

  • startedAt: The moment the GC started (Unix timestamp in milliseconds).

  • endedAt: The moment the GC ended (Unix timestamp in milliseconds).

  • duration: The time the GC has been active (difference between endedAt and startedAt).

  • gctype: Memory allocation type. According to v8 source code possible values are:

    • 1: Scavenge
    • 2: Mark/Sweep/Compact
    • 4: Incremental marking
    • 8: Weak/Phantom callback processing
    • 15: All
  • totalHeapSize: Number of bytes V8 has allocated for the heap. This can grow if usedHeap needs more.

  • totalHeapSizeExecutable: Number of bytes for compiled bytecode and JITed code.

  • usedHeapSize: Number of bytes in use by application data.

  • heapSizeLimit: The absolute limit the heap cannot exceed.

  • totalPhysicalSize: Committed size. (Node.js 0.12+)

  • totalAvailableSize: Available heap size. (Node.js 4+)

  • mallocedMemory: Current amount of memory, obtained via malloc. (Node.js 7+)

  • peakMallocedMemory: Peak amount of memory, obtained via malloc. (Node.js 7+)

  • numberOfNativeContexts: Number of the top-level contexts currently active. Increase of this number over time indicates a memory leak. (Node.js 10+)

  • numberOfDetachedContexts: Number of contexts that were detached and not yet garbage collected. This number being non-zero indicates a potential memory leak. (Node.js 10+)

  • externalMemory: Number of bytes of memory allocated outside of v8's heap. (Node.js 12+)

  • totalGlobalHandlesSize: Size of all global handles in the heap. (Node.js 14+)

  • usedGlobalHandlesSize: Size of all allocated/used global handles in the heap. (Node.js 14+)