
Company News
Socket Joins New OpenJS Program to Fund Node.js Security Work
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.
mem-pressure
Advanced tools
Monitor Node.js memory usage and emit events when thresholds are exceeded
Monitor Node.js memory usage and emit events when thresholds are exceeded
npm install mem-pressure
import MemoryMonitor, {getMemorySnapshot} from 'mem-pressure';
const monitor = new MemoryMonitor({threshold: 0.9, interval: 10_000});
monitor.addEventListener('pressure', event => {
console.log('Memory pressure detected!');
console.log(`Heap usage: ${(event.detail.heapUsedRatio * 100).toFixed(1)}%`);
});
monitor.start();
// Get a one-off snapshot
const snapshot = getMemorySnapshot();
console.log(snapshot.heapUsedRatio);
// Stop monitoring
monitor.stop();
Creates a new memory monitor instance. Extends EventTarget.
Type: object
Type: number
Default: 0.85
Heap usage ratio (0-1) at which to emit 'pressure' events.
Type: number
Default: 5000
Polling interval in milliseconds.
'pressure'Emitted when heapUsed / heapTotal exceeds the threshold. The listener receives a CustomEvent with detail set to a MemorySnapshot object.
Start monitoring memory usage. Returns this for chaining.
Stop monitoring memory usage. Returns this for chaining.
Calls .stop(). Enables use with the using declaration.
Returns a MemorySnapshot object with the following properties:
rss — Resident Set Size in bytesheapTotal — Total size of the allocated heap in bytesheapUsed — Actual memory used during execution in bytesexternal — Memory used by C++ objects bound to JavaScript objects in bytesarrayBuffers — Memory allocated for ArrayBuffer and SharedArrayBuffer in bytesheapUsedRatio — Ratio of heapUsed to heapTotal (0-1)MIT
FAQs
Monitor Node.js memory usage and emit events when thresholds are exceeded
The npm package mem-pressure receives a total of 0 weekly downloads. As such, mem-pressure popularity was classified as not popular.
We found that mem-pressure demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Company News
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.

Security News
Two compromised GitHub Actions were re-enabled with malicious tags intact, exposing thousands of downstream repositories to Mini Shai-Hulud.

Research
/Security News
A malicious Firefox extension fetches its payload after installation to evade detection, steal Google session cookies, and automate account takeover.