@cldmv/sizeofvar
v1.0.4
Published
Determines the initial memory usage of any javascript variable in NODE.JS
Downloads
5
Maintainers
Readme
sizeofvar
Description
sizeofvar allows you to get a realistic memory size of any variable upon initialization or variable setting.
Install
npm i @cldmv/sizeofvar --save
Usage
const sizeofvar = require('@cldmv/sizeofvar');
console.log(sizeofvar(variable));
Test Examples
The included tests allow you to verify that the number returned from this module represents the memory usage reported by node for a variable.
node -expose-gc test/test-mem.js command [-v]
-expose-gc
This option is required to run the memory tests. Without it you will recieve an error.
test/test-mem.js
This is the test file. It handles a command to test various variable tests.
command
Valid values are:
- array
- bool
- number
- object
- object-complex
- object-key-length
- object-string
- string