configuration max old space size in Nodejs

后端 未结 2 544
南旧
南旧 2020-12-16 12:54

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 erro

相关标签:
2条回答
  • 2020-12-16 12:54

    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.

    0 讨论(0)
  • 2020-12-16 13:19

    you could add the following to your package.json

    "scripts": {
        "start": "node --max-old-space-size=102400 ./app.js",
         ......
    }
    

    this is unlike the other way has to write only once and configured each run time. Note: you no need to run explicitly this command the npm start will take care of configuring it each time

    0 讨论(0)
提交回复
热议问题