在Node.js中配置最大旧空间大小 [英] configuration max old space size in Nodejs
问题描述
我是nodejs和mongodb中的新手.当我从nodejs应用程序中的mongodb中读取大约100000条记录时,我遇到了问题. 当我尝试获取100000条记录时,出现此错误:
Im a newbie in nodejs and mongodb. I have a problem when i read about 100000 records from my mongodb in nodejs application. When I try to get 100000 records, I got this error:
致命错误:CALL_AND_RETRY_LAST分配失败-内存不足
我在Google上搜索时,每个人都说配置最大旧空间大小参数是因为v8引擎大约有1,9Gb堆内存.
I search google and everyone said that configure max old space size parameter because v8 engine have about 1,9Gb heap memmory.
我的意思是,我通过eclispe运行我的应用程序,但我不知道如何配置max-old-space-size参数.
My point is, I run my app by eclispe, and i dont know how to configure max-old-space-size parameter.
有人可以提示吗?
非常感谢您!
ps:我的英语不好,所以如果你听不懂我的问题,那很好.
ps: my english is bad so if you cannot understand my question, it's fine.
推荐答案
使用node --max_old_space_size=5000 yourapp.js
允许5000 mb.在Eclipse启动设置中查找命令行参数,您可以在其中添加此参数.
Use node --max_old_space_size=5000 yourapp.js
to allow 5000 mb. Look in your eclipse launch settings for command-line parameters, where you can add this.
但是,正如评论所说,您应该重新考虑将其加载到内存中,然后将其流式传输到客户端.
However, as the comments say, you should reconsider loading this into memory, and stream it to the client instead.
这篇关于在Node.js中配置最大旧空间大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!