有没有一种方法来扩展过程1GB当前工作集? [英] Is there a way to expand the current WorkingSet of a process to 1GB?

查看:193
本文介绍了有没有一种方法来扩展过程1GB当前工作集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/12228321/is-there-any-way-to-force-the-workingset-of-a-process-to-be-1gb-in-c">Is有什么办法来强制处理的工作集为1GB的C ++?

我们想增加一个.NET过程,1GB的工作集,提前,以避免页面错误。

We would like to increase the WorkingSet of a .NET process to 1GB, in advance, to avoid page faults.

有没有办法做到这一点。NET中?

Is there a way to do this in .NET?

更新

不幸的是,看来,就算我们做一个调用的 SetProcessWorkingSetSizeEx ,垃圾收集修剪工作定了下来,无论如何,绕过MinWorkingSet(见自动GC.Collect的()如下图)。

Unfortunately, it appears that even if we do a call to SetProcessWorkingSetSizeEx, the garbage collection trims the working set down anyway, bypassing MinWorkingSet (see "Automatic GC.Collect() in the diagram below).

在下面的图片中,有没有办法锁定进程工作集(绿线)到1GB,以避免在分配新的内存插入过程中出现页面错误(红色线)秒杀?

In the picture below, is there a way to lock the process WorkingSet (the green line) to 1GB, to avoid the spike in page faults (the red lines) that occur when allocating new memory into the process?

的原因,这将是真棒,就是每一个页面错误发生时,它会阻止线程250US,这伤害到应用程序的性能不好。

The reason this would be awesome is that every time a page fault occurs, it blocks the thread for 250us, which hits application performance badly.

更新

引用自:通过C / C ++的Windows,第五版,杰弗里里希特(Wintellect的)

Quote from: "Windows via C/C++, Fifth Edition, Jeffrey Richter (Wintellect)"

调用由一个单独的进程SetProcessWorkingSetSize被忽略   除非进程只是试图清空其工作集。设置   此限制,指定JOB_OBJECT_LIMIT_WORKINGSET国旗在   LimitFlags成员。

Calls to SetProcessWorkingSetSize by an individual process are ignored unless the process is just trying to empty its working set. To set this limit, specify the JOB_OBJECT_LIMIT_WORKINGSET flag in the LimitFlags member.

这本书暗示设置工作集的唯一方法是通过分配过程中作业对象和设置JOB_OBJECT_LIMIT_WORKINGSET和MinimumWorkingSetSize。

This book is implying that the only way to set the WorkingSet is by assigning the process to a Job Object and setting JOB_OBJECT_LIMIT_WORKINGSET and MinimumWorkingSetSize.

更新

SetProcessWorkingSetSizeEx有绝对无关,与软页面错误。它仅是指硬页面错误,因为它prevents内存在目前的工作集被调出到硬盘驱动器。

SetProcessWorkingSetSizeEx has absolutely nothing to do with soft page faults. It only refers to hard page faults, as it prevents memory in the current WorkingSet being paged out to the hard drive.

更新

事实证明,以增加工作集的唯一方法就是使用一个非常专业的运行.NET CLR主持人用C ++编写(见我的回答如下)。

It turns out that the only method to increase the WorkingSet is to run .NET using an extremely specialized CLR Host written in C++ (see my answer below).

推荐答案

这是我们能找到的提高进程的工作集在.NET下,能减少软页面错误的唯一方法,就是运行在整个.NET应用程序自定义 CLR主机。这是一个不平凡的工作,需要大约800线的自定义编写的,而密集的C ++ code。在C ++ code拦截.NET调用Win32的内存管理方法,改变.NET运行时的行为,所以它不会释放内存积极,因为它通常会。

The only way that we could find to increase the WorkingSet of a process under .NET, to reduce soft page faults, was to run the entire .NET application under a custom CLR Host. This is a non-trivial exercise, requiring about 800 lines of custom written, rather dense C++ code. The C++ code intercepts the .NET calls to the Win32 memory management methods, altering the behavior of the .NET runtime so it doesn't free memory as aggressively as it normally would.

这已经招致所有软页面错误的时候,应用程序启动时,使正常的应用程序执行期间,在.NET应用程序的软页面错误数降至pretty的很多零的效果。

This has the effect of incurring all of the soft page faults when the application starts up, so that during normal application execution, the number of soft page faults in the .NET app drops pretty much to zero.

这意味着应用程序可能是内存饿了,但它的运行速度更快。换句话说,我们牺牲内存使用增加的实时性能。

This means that the application may be memory hungry, but it runs faster. In other words, we are sacrificing memory usage for increased realtime performance.

这篇关于有没有一种方法来扩展过程1GB当前工作集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆