简体   繁体   English

堆稳定,而rss增加node.js

[英]Heap stable while rss increases node.js

I have an app written in node.js and it works as it should. 我有一个用node.js编写的应用程序,它可以正常工作。 The only problem is that the memory keeps increasing 'till it hits 1.3Gb and immediately drops to ~400Mb. 唯一的问题是内存一直在增加,直到达到1.3Gb并立即下降到约400Mb。 At first I though it's a memory leak, but further investigation shows there's no leaks. 起初我虽然是内存泄漏,但是进一步的调查显示没有泄漏。

内存使用情况

The analyze of heap-dump doesn't give any useful information, just proves that there's no leak. 堆转储的分析没有提供任何有用的信息,只是证明没有泄漏。 I'm using node.js v4.2.1 and the application is heavily using websockets (socket.io) with transports set to ['websockets'] only. 我正在使用node.js v4.2.1并且该应用程序大量使用websockets (socket.io) ,其传输设置仅为['websockets'] For load balancing I'm using PM2 in cluster mode (4 instances) . 为了实现负载平衡,我PM2 in cluster mode (4 instances)使用PM2 in cluster mode (4 instances)

What could be the reason? 可能是什么原因? What are the consequences? 有什么后果? Do you think it might crash the server in the long run? 从长远来看,您认为它可能会使服务器崩溃吗?

If you plan to distribute the load of connections among different processes or machines with pm2 , you have to make sure that requests associated with a particular session id connect to the process that originated them. 如果计划使用pm2在不同进程或计算机之间分配连接负载,则必须确保与特定会话ID关联的请求连接到发起它们的进程。 If it connect wrong process , it will make a mass of request ajax to server . 如果连接错误的进程,它将向服务器发出大量的请求ajax。 You can use inspector in browser to check it, refresh web an check socket run correctly. 您可以在浏览器中使用检查器进行检查,刷新Web并正确运行检查套接字。 It will make memory increase faster and when it to limit , It will call gc(). 它将使内存增加更快,并在达到限制时调用gc()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM