Record my windbg debugging journey.
Problem description:
There is a project with a high CPU jump. Please come out immediately for windbg
1. adplus packet capture;
2. windbg open the file and run. Load SOS;
3. Run! Threads, found that the process 71 and 77 have exceptions, GC is disabled;
4 .~ 71 s switch to this thread ,! Clrstack view hostingCodeTo see which page it is. The page is imei_list.aspx;
5 .! DSO, a string is found to report the following error:
0: 071>! Dsoos thread ID: 0x11ec (71) ESP/REG object name1d1af0d4 156bd9e8 system. String <string is invalid or too large to print>
6 .! The following result is displayed for the objsize: 6.3 MB, which is not a small string. No wonder! Do cannot be printed
0: 071>! Objsize 156bd9e8 sizeof (156bd9e8) = 6346824 (0x60d848) bytes (system. String)
7. this time I want to check the code. Open the project and find the file. The file business is very simple: get the list of IMEI strings of a user's mobile phone, splice all the IMEI strings, and then output them. It is very simple, there shouldn't be any problems. The only question is how big the IMEI list is.
8. connect to the database and open the process. There is only one statement in the process: Select * From t_imei where userid = @ userid. If userid = 0, how much data will there be, because the parameters passed in on this page are exactly 0, it's no wonder that more than 6000 records are obtained after query.
Now I finally understand that because this is not frequently accessed (about 1 time/second), each time it will produce a string of M, GC constantly needs to work, resulting in a high CPU, a simple changeProgramAnd the storage process, everything is OK, CPU from 40% down to less than 10%.