C # solution to a memory overflow error in the program

Source: Internet
Author: User

A memory overflow error occurs on the website developed with C #: "The System. OutOfMemoryException type is thrown"

Because many pages are difficult to identify the source of the problem at the beginning, the code that caused memory overflow was found for a long time. Summarize this method.

Symptom: A memory overflow error occurs at a time, and a large number of page requests are blocked on the server. After the iis program pool is recycled, it will be normal for a short time, but after a period of time, memory overflow occurs again. The time interval is different and there is no regularity.

Solution: 1. Identify the memory overflow error caused by a page request.

2. Search for problematic pages

Pages with memory overflow error codes should not be executed when requested.

Therefore, the OnPreInit method records the address and request time of the page to the database when all pages are requested. Each request adds a record to the database.

When the OnUnload method is executed on the page, update the total execution time of the page to the request record mentioned above. (When added, the total execution time is-1 by default)

Through the above method, analyze the pages that are not executed when memory overflow occurs several times. The final problem page is located. After the code is modified and uploaded, the memory overflow problem is solved.

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.