Record the analysis and solution of PC software thread leakage

The host computer software at the customer site said after a period of time that there was no response after operation, but the host computer did not die, and some strange phenomena occurred:

  • The time in the upper left corner does not move (originally it runs once every 1 second)
  • Use the task manager to view it. The memory occupies 1.5G and there are more than 3000 threads. Under normal circumstances, there should be about 400 threads and the memory is within 500M (there are many devices).
    This analysis is more concerned about thread leaks and why threads keep increasing.
    Solution:

1. Manual snapshot memory Dump file

Insert image description here

2. Directly use VS2022 to analyze the Dump file

Insert image description here
Select the stored dmp file, it will load symbols online
Insert image description here
Click on the top right 运行分析诊断:
Insert image description here
Click the分析button
Insert image description here
and some analysis appears below. Then click on each one for details.

Insert image description here
Insert image description here
From here you can probably find some clues indicating which function has the problem.
The probable reason for the final analysis is the extensive use of asynchronous code in threads. The code will be posted later.

Guess you like

Origin blog.csdn.net/lishuangquan1987/article/details/134336813