[英]How to solve node.js “JavaScript heap out of memory” problem?
I'm running a node.js service on my Ubuntu 16.04 server.我在 Ubuntu 16.04 服务器上运行 node.js 服务。 I came across a problem recently, where I get this error message:
"UFATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory"
.我最近遇到了一个问题,我收到此错误消息:
"UFATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory"
。
Now, I read here on SO that I can use something like: node --max-old-space-size=4096 yourFile.js
to fix this, however I don't start my service like that, I use supervisorctl start <servicename>
to start the service.现在,我在这里阅读了所以我可以使用类似的东西:
node --max-old-space-size=4096 yourFile.js
来解决这个问题,但是我没有像那样启动我的服务,我使用supervisorctl start <servicename>
启动服务。 So, I am not sure how can I solve th problem in my case.所以,我不确定如何解决我的问题。 Can you suggest what should I do?
你能建议我该怎么做吗?
supervisorctl use of a configuration file. supervisorctl使用一个配置文件。 It should be placed somewhere like :
它应该放在像这样的地方:
/etc/supervisor/conf.d/myapi.conf
and look like :看起来像:
[program:my-api]
command=node /home/myuser/myapi/app.js
autostart=true
autorestart=true
environment=NODE_ENV=production
stderr_logfile=/var/log/myapi.err.log
stdout_logfile=/var/log/myapi.out.log
user=myuser
add the running option inside of it :在其中添加运行选项:
[program:my-api]
command=node --max-old-space-size=4096 /home/myuser/myapi/app.js
autostart=true
autorestart=true
environment=NODE_ENV=production
stderr_logfile=/var/log/myapi.err.log
stdout_logfile=/var/log/myapi.out.log
user=myuser
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.