memuse
Version:
Memory monitoring module
52 lines (39 loc) • 1.33 kB
Markdown


Javascript library to record memory utilization statistics (rss,heapTotal,heapUsed,external,arrayBuffers) and generate a lines chart svg file.
You can add a tag to the statistics whenever you need into your code so you could easily locate which piece of code is running when polling the statistics.
## Usage:
```
// load the library
const memuse=require('memuse')
// or if you want to reuse accross all your code
global.memuse=require('memuse')
// create an empty file to record statistics
memuse.init('./mem.csv')
// append a new line to the file with current statistics
memuse.poll()
// append a new line to the file with current statistics AND a tag message
memuse.tag('this is a message')
// generate lines chart into SVG file
memuse.end('./mem.svg')
```
Here is an example:
```
const memuse=require('memuse')
const randomstring = require('randomstring')
memuse.init('./mem.csv')
let array=[]
for (let index = 0; index < 10000; index++) {
array[index]=randomstring.generate(32)
memuse.poll()
}
memuse.tag('start deletion')
for (let index = 0; index < 10000; index++) {
array.splice(index)
memuse.poll()
}
memuse.end('./mem.svg')
```
Which produce:
