node. JS Memory leak issue Record

Source: Internet
Author: User





Let's talk first. The ins and outs of things.


Company to develop a game chess game, server development is IO-intensive, the development of the time, considered the use of python,java,node.js.
Finally chose the node. JS (node. JS propaganda killer feature. Asynchronous io,node.js Another branch called Io.js), and that's where things start.


Because the first time to do mobile games. The estimated shortage of mobile networks. JSON is selected as the communication data transfer format. On-line players are frequently dropped off the line (the amount of traffic data is too large, mobile network cannot hold),
So think of a solution, the JSON data compressed with zip, things seem to be all right (although there are a lot of players react to the problem, but the situation is very much better).
It's time to start. We don't have many players. CPU utilization is not high. System all right, and then more and more players, there has been a problem server development long-running problem memory leaks.
Every few days, the player's memory goes up. Memory leaks are not too serious for our system. It can be restarted every few days.






Step1. Start analyzing our code. Looking at those codes can lead to memory leaks due to memory leaks occurring in our gateway process. The amount of code is less,
A lot of time has been studied, and many things have been suspected, but the test code written is not verifiable.

The problem just drags on, write a timer script and restart the gateway process at some point.


Step2. Things just put down, every time, think of this problem, and tangled. Start doing a second project (the second project uses MQTT.)
And a set of codec code that Protobuf himself wrote, which overcomes the problem of too much JSON data. The project is not successful, the user is not many users at the moment, the system does not have a memory leak problem.




Step3. Colleagues suddenly remembered that it would be because the ZIP compression JSON data consumes the CPU, we envision the business is IO-intensive. Now it's CPU intensive. CPU-intensive, and then node.j the GC work out of the question?.





node. JS Memory leak issue Record

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.