ivanhuay / memory-consumer

Library made just to consume memory.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory Consumer

Library made just to consume memory.

why?

  • Testing high memory usage cases.
  • Consume memory.

Usage

Basic usage:

--max-old-space-size property is probable needed

const MemoryConsumer = require('memory-consumer');

const consumer = new MemoryConsumer();

consumer.fillMemoryMb(500); //consume approx 500mb
consumer.fillMemoryMb(1024); //consume approx 1gb

Show logs

const MemoryConsumer = require('memory-consumer');

const consumer = new MemoryConsumer(true);

consumer.fillMemoryMb(500); //consume approx 500mb
consumer.fillMemoryMb(1024); //consume approx 1gb

Arguments

MemoryConsumer(Boolean logsEnabled, Integer logInterbalMs)

Methods

fillMemoryMb(int):

consume number of MB.

enableLog():

just enable logs .

disableLog():

just disable logs.

setLogInterval(intervalMS):

set the iterval miliseconds for logs.

cleanMemory():

clean the memory storage. (it could take some time until the garbage collector really cleans the memory)

getUsedMemory():

returns used memory string

About

Library made just to consume memory.


Languages

Language:JavaScript 100.0%