3

I'm writing a little PerformanceTest programm and I try to artificially restrcit the memory that can be used during the test. Some of the tests taking some hours to run while processing multiresolution images up to some 100 GB.

Ideal would be to set the restrictions per thread but I think this will not work. The tests are executed in a separate process or in a separate AppDomain. I know how to monitor (but not restrict) the resources of an AppDomain with ARM and ETW and I have tried to set the MaxWorkingSet on process level but this has no effect until the systems memory is under pressure.

Of cause, there are other ways and workarounds to accomplish this e.g by running the tests in a VM or restricting windows memory on boot options. Starting a second process that allocates huge amount of memory.

Is there any way to artifically restict the pysical memory a process/AppDomain can use even if there is free physical memory available on the system? May be it is posible to restrict the virtual memory too?

4

1 回答 1

0

不知道任何可用的此类功能,但我会限制内存消耗(与使用情况相反)。

因此,当您启动测试时,它将有一个计数器来记录它可以创建和操作的对象/线程数。如果计数器值达到其最大允许值,则测试将等待,直到其中一个线程/对象完成作业。

如果你使用Parallel类,你可以设置最大并行度

于 2013-07-18T09:15:29.860 回答