如何克服NodeJS堆内存错误? [英] How to overcome NodeJS heap memory error?
问题描述
我的NodeJS中有一个已连接的数据库,其大小为723.1 MB,但是在内存大小方面也面临着同样的麻烦.
I have a connected database in my NodeJS with 723.1 MB in size but facing the same trouble about memory size.
我正在做的是将数据库创建为API,以便可以在VueJS中请求它.我使用大小仅为0.1 MB的虚拟数据库成功地将所有数据呈现为所需的API.
What I am doing is am making my database as API so that I can request it in my VueJS. I successfully render all the data as API needed using my dummy database which is only 0.1 MB in size.
我已经尝试过使用此代码来增加在节点中分配的内存
What I already tried is to increase the memory allocated in node using this code
node --max-old-space-size=2048 index.js
但是什么也没发生,我遇到了同样的问题.我该怎么办才能解决此类问题?
But nothing happens, I faced the same issue. What can I do to solve this kind of problem?
推荐答案
尝试将旧空间的大小增加到4096,而不是2048
Try increasing old space size to 4096 rather than 2048
node --max-old-space-size=4096 index.js
这篇关于如何克服NodeJS堆内存错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!