Memory usage in. net

Source: Internet
Author: User

Today, we started to solve the problem of excessive system memory usage.

When we started the system last year, we found that the system occupied a large amount of memory. By June this year, the system started and occupied 60 MB of memory, after running for a period of time, it reaches about MB (the result of monitoring by the task manager). At that time, there are no solutions (including GC. collect, destructor, etc.), and later discussed with the source of inspiration on MSN, he thought it may be the problem of using magiclibrary in the system, so it was put on hold.

I found my blog on the Internet and some people have discussed it. Zhiqiu yiye gave a wonderful explanation. After reading it, I felt a sense of excitement. In the system, the setprocessworkingsetsize method is used for a test. After this method is called, the occupied memory is reduced from 80 Mb to 2 MB. (results observed by taskmanager) According to Zhiqiu yiye, adjusting workingset may lead to page-missing interruptions, seriously affecting performance. However, from the usage perspective, we have not found such a phenomenon. This may be the reason why I used this method:

Public   Static   Int Minof ( Uint PID)

{

Intptr HD = OpenProcess (( Uint ) Process_access_rights.process_set_quota, False , Pid );



Try  

{

If (HD ! = Intptr. Zero && System. environment. osversion. Platform = System. platformid. win32nt)

{

ReturnSetprocessworkingsetsize (HD,-1,-1);

}

Else  

{

Return -1;

}

}

Finally  

{

Closehandle (HD );

}

}

AboveCodeFrom http://www.zpcity.com/ArLi//commonprj/cls_MinWorkSize.cs

According to Zhiqiu yiye, the system does not make much sense to adjust the workingset in this way. However, it is not very nice to look at the numbers in TASKMANAGER.

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.