Mark a high CPU problem caused by GC

Source: Internet
Author: User

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%.

 

 

 

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.