sizeofvar allows you to get a realistic memory size of any variable upon initialization or variable setting.
npm i @cldmv/sizeofvar --save
const sizeofvar = require('@cldmv/sizeofvar');
console.log(sizeofvar(variable));
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]
This option is required to run the memory tests. Without it you will recieve an error.
This is the test file. It handles a command to test various variable tests.
Valid values are:
- array
- bool
- number
- object
- object-complex
- object-key-length
- object-string
- string
This project exists thanks to all the people who contribute. [Contributors].