如何找出 Windows 上的交换空间使用情况

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3605287/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:08:50  来源:igfitidea点击:

How to find out swap space usage on windows

windowswinapiswapfile

提问by eric young

I want to monitore swap space usage on windows 2003 server. If the usage is over 80% for 10 minutes, an alarm will be generated. There are lot of tools for RAM, but how about swap usage? How do I simulate that condition and do the test?

我想监视 Windows 2003 服务器上的交换空间使用情况。如果使用率超过 80% 持续 10 分钟,则会产生警报。RAM 有很多工具,但是交换使用情况如何?我如何模拟该条件并进行测试?

回答by Preet Sangha

To force the page file to be used. Start Commiting Memmory. Use the VirtualAllocapi call:

强制使用页面文件。开始提交内存。使用VirtualAllocapi 调用:

LPVOID WINAPI VirtualAlloc(
  __in_opt  LPVOID lpAddress,
  __in      SIZE_T dwSize,
  __in      DWORD flAllocationType,
  __in      DWORD flProtect
);

and set flAllocationType to MEM_COMMIT (0x1000), this should start memory being used. Once memory is suffcient exhausted, then the page file should be automatically employed. I suspect you'll have to start measuring usage and then determine heuristically as to when %usage you require happens.

并将 flAllocationType 设置为MEM_COMMIT (0x1000),这应该启动正在使用的内存。一旦内存足够耗尽,则应自动使用页面文件。我怀疑您必须开始测量使用情况,然后启发式地确定您需要的 %usage 何时发生。

To monitor it read the performance counters. The paging file set has a %usage counter you can read. Start here on how to consume them. All you need is to create a windows service that reads the info and then rings the appropriate alarms.

要监视它,请读取性能计数器。分页文件集有一个可以读取的 %usage 计数器。从这里开始了解如何使用它们。您所需要的只是创建一个 Windows 服务来读取信息,然后响起相应的警报。

.Net : http://blogs.msdn.com/b/bclteam/archive/2006/06/02/618156.aspxC++ : http://msdn.microsoft.com/en-us/library/aa373219(v=VS.85).aspxor http://msdn.microsoft.com/en-us/library/aa373214(v=VS.85).aspx

.Net:http: //blogs.msdn.com/b/bclteam/archive/2006/06/02/618156.aspxC++:http: //msdn.microsoft.com/en-us/library/aa373219(v= VS.85).aspxhttp://msdn.microsoft.com/en-us/library/aa373214(v=VS.85).aspx

回答by Bukes

Use the built-in performance counters. You can fetch them via WMI/Win32_Perf:

使用内置的性能计数器。您可以通过 WMI/Win32_Perf 获取它们:

http://msdn.microsoft.com/en-us/library/aa394270%28v=VS.85%29.aspx

http://msdn.microsoft.com/en-us/library/aa394270%28v=VS.85%29.aspx

or the raw Performance counter/registry interfaces:

或原始性能计数器/注册表接口:

http://msdn.microsoft.com/en-us/library/aa373083%28v=VS.85%29.aspx

http://msdn.microsoft.com/en-us/library/aa373083%28v=VS.85%29.aspx