ASP. NET memory usage was so crazy that I almost crashed. Fortunately, it was solved.

Source: Internet
Author: User
Some of the previously written ASP. NET pages are used for data selection, that is, the qualified records are displayed and one of them is selected by the user. To speed up, all the qualified data is taken out and placed in the session. You can retrieve the data directly during paging search. It has been running normally (haha, maybe it is not normal, but it was not seen). Later, I switched to a system with a large data volume, after the data is selected several times, the memory usage reaches more than 1 GB, resulting in memory exceeding the limit of the process collapsed.
The data is stored in the session. When the session is exited, the data is cleared based on the related key value, which should be released. However, even if I add a forced garbage collection function CodeIt does not work.
No way. Read the code. You know what the problem is. A new table is generated for paging, and the table is bound to a custom DataGrid and stored in the session. This part is managed by the DataGrid and is not cleared when exiting. However, this table contains only 10 rows of data (the default value), and opening the same option for the same user will overwrite the previous cache, so such a large memory usage should not occur.
You have to do this in the cached data Article. The cached dataview is actually a defaview view of a datatable, When you exit the page, call cachedata. Table. Clear () to clear the data in the datatable.,Then cachedata. dispose (), and then use the original processing to clear the cached data in other sessions (a few signs, it cannot be any climate), add a method in the DataGrid to clear the cache, and then forcibly recycle the garbage, run, test, view memory, haha, always stable at 40 ~ 50 m.
The connection times out due to a large data query. In the official system on the server, multiple ie access and tests are enabled, which is basically stable at around MB. Successful!
If necessary, it is better to clear the large object if it is not used. Because this part of the code was written earlier, I thought that. net should be able to be automatically recycled, so I didn't care about this problem at the time. I think this code is still relatively weak.

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.