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.