I store some JSON files on disk (each very small about 4kB), and load them into a var when required. I may have thousands of such files, and if the space they occupy in memory is the same as what they occupy on disk, I would rather load them all into memory at application start.
How can I calculate how much memory (RAM) the file occupies when I create an object from it ?
EDIT: I know how to save JSON files to disk. That is not my question. I am trying to understand how much memory (RAM), a JSON file will occupy when I load it into a var. If I know the size of the JSON file on disk, how can I calculate how much memory (RAM) it will occupy when I create a javascript object from the file in node.js or in a web browser ?
The files are saved as "plain text files". Eg:
{"foo": {
"bar": 1,
"foo": {
"bar": [
"foo",
"bar"
],
"foo":[
"bar",
"foo"
]
}
}
}