
Security News
crates.io Ships Security Tab and Tightens Publishing Controls
crates.io adds a Security tab backed by RustSec advisories and narrows trusted publishing paths to reduce common CI publishing risks.
memory-usage
Advanced tools
A readable stream that samples and emits memory usage over time.
You can for instance use the output to graph your memory usage.
For CLI usage:
npm install memory-usage -g
For programmatic usage:
npm install memory-usage --save
Use the memory-usage command instead of the node command:
memory-usage server.js
Sample memory usage every 2 seconds and write it to a CSV file:
var fs = require('fs')
var csvWriter = require('csv-write-stream')
var memoryUsage = require('memory-usage')
memoryUsage(2000)
.pipe(csvWriter())
.pipe(fs.createWriteStream('memory.csv'))
Note that you application of course have to do some actual work. If you just run the example above as is, the node process will simply exit after creating an empty file.
If you want to chart the memory usage, I recommend combining this module with chart-csv.
stream = memoryUsage([freq|options])Will start sampling memory usage every freq milliseconds (defaults to
5000) as soon as the stream is flowing.
The optional options object expects the following properties:
freq - The sampling frequency in milliseconds (defaults to 5000)ts - A boolean specifying if a timestamp should be outputtet along
with the memory samples (defaults to false)gc - A boolean specifying if garbage collection should be profiled
and logged along with the memory samples (defaults to false)The stream emits samples in the form of JavaScript objects:
{
rss: 4935680, // Resident set size: Memory assigned to the process in bytes
heapTotal: 1826816, // V8 heap memory allocated in bytes
heapUsed: 650472, // V8 heap memory used in bytes
ts: 1479179912921, // UNIX epoch timestamp for sample in milliseconds (only present if `optsions.ts` is `true`)
gc: null // Indicates if sample was taken after a garbage collection run (only present if `options.gc` is `true`)
}
If the gc property is null, it means that the sample wasn't taken
after a garbage collection run. If the value is a string, it will
indicate the type of garbage collection run. Currently, the values can
be either Scavenge or MarkSweepCompact.
Note that samples indicating a garbage collection run might be a few hundred milliseconds delayed. This means that you might see a regular timed sample appear prior in the stream with reduced memory usage, even though there's no official indication of a garbage collection run yet.
MIT
FAQs
A readable stream that samples and emits memory usage over time
We found that memory-usage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
crates.io adds a Security tab backed by RustSec advisories and narrows trusted publishing paths to reduce common CI publishing risks.

Research
/Security News
A Chrome extension claiming to hide Amazon ads was found secretly hijacking affiliate links, replacing creators’ tags with its own without user consent.

Security News
A surge of AI-generated vulnerability reports has pushed open source maintainers to rethink bug bounties and tighten security disclosure processes.