优化Node.js的内存消耗 [英] Optimize Node.js memory consumption

查看:130
本文介绍了优化Node.js的内存消耗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Node.js,Express和MongoDB编写一个简单的cms.我打算为每个站点运行一个不同的Node.js进程.问题在于,启动后,该过程需要大约90m的RAM,对我来说,它太大了(八个站点占用了所有服务器RAM).在首次连接到站点后,将占用此内存,而其他连接不会影响该内存.

I'm writing a simple cms in Node.js, Express and MongoDB. I'm planning to run a different Node.js process for every site. The problem is that after startup the process takes about 90m of RAM and for me it's too big (eight site take all server RAM). This memory is taken after the first connection to the site and other connections don't affect the memory.

是否存在用于优化此内存使用量的指南或最佳实践"列表?我正在尝试使用process.memoryUsage()或类似函数来跟踪内存的分配位置,但这并不容易.

Is there a guideline or a list of "best practices" to optimize this memory usage? I'm trying to track where the memory is allocated with process.memoryUsage() or a similar function but it's not simple to do this.

这不是内存泄漏或类似问题的问题,因为在第一次连接后内存使用率并没有增加,因此优化可能是加载较少的模块或采取其他措施...

Is not a problem of memory leaks or something similar because the memory usage doesn't grow up after the first connection, so probably the optimization could be in loading less modules or do something differently...

推荐答案

下面的链接可以帮助您了解和检测内存泄漏(如果确实存在):

The links below may help you to understand and detect memory leaks (if they do exist):

在node.js中调试内存泄漏

检测Node.js中的内存泄漏应用程序

这些SO问题也可能有用:

These SO questions may also be useful:

如何监视Node.js的内存使用情况?

Node.js内存泄漏搜索

这篇关于优化Node.js的内存消耗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆