visible-memory-usage
v1.3.0
Published
Display memory usage as bars in the console.
Downloads
3
Maintainers
Readme
Visible Memory Usage v1.3.0 Documentation
Table of contents
Description
Node.js package for displaying memory usage as bars in the console. In
order to make this library work, it is necessary to pass a Node.js cli
argument --max-old-space-size
.
Installation
npm i -D visible-memory-usage
Usage example
import { VisibleMemoryUsage } from 'visible-memory-usage'
const visibleMemoryUsage = new VisibleMemoryUsage()
visibleMemoryUsage.showMemoryUsage()
setTimeout(
() => visibleMemoryUsage.hideMemoryUsage(),
4e3 // Hide in 4 seconds
)
API
class VisibleMemoryUsage
constructor(fps: number = 60, memoryType: MemoryType = "rss")
- fps (number): (Frames Per Second) is the frequency at which memory
usage will be updated. Its value can be from
1
to60
. Lower the value, lower the CPU load will be. Default is60
. - memoryType (string): memory types are the keys of the Node.js
process.memoryUsage()
returned object and those are:'rss' | 'heapTotal' | 'heapUsed' | 'external' | 'arrayBuffers'
. Default value is'rss'
- fps (number): (Frames Per Second) is the frequency at which memory
usage will be updated. Its value can be from
- showMemoryUsage(): method is used to display the memory.
- hideMemoryUsage(): method is used to hide the memory.
Tip
Can be helpful when you are trying to find a memory leak.