最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - Javascript object maxium memory size - Stack Overflow

programmeradmin2浏览0评论

Currently i am doing a simple db migration through Javascript. I find myself wanting to keep track of some simple id -> object maps to make less SQL db calls.

So the question is, what is the maximum size of a javascript object in node? Say i have a very simple table with 2000 records. I am only interested in two columns, is it possible for me to just store all these values under a plain JS object that looks like {id1: {col1: "foo", col2: "bar"}, id2: {col1: "ss", col2: "bb"}} ??

If 2000 is okay, what is the maximum that i can do?

Currently i am doing a simple db migration through Javascript. I find myself wanting to keep track of some simple id -> object maps to make less SQL db calls.

So the question is, what is the maximum size of a javascript object in node? Say i have a very simple table with 2000 records. I am only interested in two columns, is it possible for me to just store all these values under a plain JS object that looks like {id1: {col1: "foo", col2: "bar"}, id2: {col1: "ss", col2: "bb"}} ??

If 2000 is okay, what is the maximum that i can do?

Share Improve this question edited May 20, 2016 at 4:48 Jonathan Lonowski 124k35 gold badges202 silver badges202 bronze badges asked May 20, 2016 at 4:31 Zhen LiuZhen Liu 7,93215 gold badges56 silver badges104 bronze badges 4
  • 1 It obviously depends on browser implementation – vp_arth Commented May 20, 2016 at 4:41
  • Why don't you just test it? – user663031 Commented May 20, 2016 at 6:01
  • @vp_arth I was talking about node. – Zhen Liu Commented May 20, 2016 at 15:23
  • read browser as engine – vp_arth Commented May 20, 2016 at 15:27
Add a ment  | 

2 Answers 2

Reset to default 4

It's NO PROBLEM

In my app, I just store some logs in an Array instance and set a length limit of 10000;

var maxListLength = 100000; This make the Array instance size reach to 50MB more or less;

And when the app is running, there may be 100 of this kind of instance, but with no problem;

What should you do is to increase memory limit for Node process in V8:

node --max-old-space-size=4096 your_app.js

According to this issue on V8. Chrome can support no more than 2GB of object in memory.

https://bugs.chromium/p/v8/issues/detail?id=847

发布评论

评论列表(0)

  1. 暂无评论