This is a created article in which the information may have evolved or changed.
Because IP storage, the need to convert the IP into an integer, so that more space-saving, while searching relatively fast, so the code needs a Ip2long function. The project is a background to perform the task, constantly accept requests, warehousing. Google for a while, on the internet to find a Golang version of the Ip2long code, is used in the project, the code is as follows:
Project in the intranet stress test process, found that after a few hours of execution, the process becomes a zombie process, the process has been there, but it is not found in processing data. Once the process is restarted, the data can be processed again. The first estimate may be a deadlock, the process has been waiting, looking for a long time, did not find the problem. Suddenly to see the memory footprint of the process, found up to 4-5g, and memory has been increasing, the initial estimate is a memory leak it. Go tool pprof analysis found this function memory consumption super High:
Very strange, why is a regular memory consumption so high?
Modify the Ip2long function as follows:
Run the program again, after a while to find that the memory consumption is not so high! Is there a memory leak in the Golang version of the recumbent slot? How can a regular memory footprint be that high?