草庐IT

javascript - Node : Why pm2 list shows memory keeps on increasing?

coder 2025-03-15 原文

我将 HAPI.JS 框架与 NodeJS 结合使用并创建了一个代理。认为代理意味着我只是在 redis 中维护 session 。除此之外,我没有在代码中做任何事情。可能唯一的问题是我每 3 分钟使用 setInterval 记录我的 process.memoryUsage()。

我的问题:

  1. 为什么我的内存力一直在增加?
  2. 它会下降吗?
  3. 发生这种情况是否是因为 setInterval 不断记录进程使用情况?
  4. 这是由于每个请求和响应的控制台日志记录导致的吗?
  5. 我的 Redis 数据库一直保持打开状态,直到我的服务器崩溃,这是造成这种情况的原因吗?
  6. 我是否需要使用流程管理器(如 new relic 或 strong loop)来识别它?
  7. 那么这个内存会持续增加多久,在某个点它必须停止(我想知道那是哪一点?)
  8. 我正在使用池概念使用 MSSQL 事务的续集?合并可以做到这一点吗?

P.S 我是 Node JS 的新手。

最佳答案

  1. Why my Memory Keeps on Increasing?

内存泄漏

  1. Will it get down?

有时 GC 会启动并清理一些东西(没有泄漏)

  1. Is this occurs due to setInterval keeps on logging the process usage?

通常不会,但是没有看到代码我不能肯定地说

  1. Is this occurs due to console logging of every request and response?

通常不会,但是没有看到代码我不能肯定地说

  1. My Redis Database is kept open till my server crashes, it this causes this ?

应该不是问题。

  1. Do i need use process mananger like new relic or strongloop to identify this?

这是一种方法……但还有其他方法。

  1. So how long this memory will keep on increasing, at some point it must stop (i want to know which point is that?)

取决于服务器设置。多少 RAM + 还有什么正在运行等。

  1. I am using sequelize of MSSQL transaction using pooling concept? Does pooling makes this?

通常不会,但是没有看到代码我不能肯定地说

也许这篇文章可以帮助您找到漏洞:
https://www.nearform.com/blog/how-to-self-detect-a-memory-leak-in-node/

关于javascript - Node : Why pm2 list shows memory keeps on increasing?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29692891/

有关javascript - Node : Why pm2 list shows memory keeps on increasing?的更多相关文章

随机推荐