Windwos Server 2008 中经常有物理内存占用较高,但任务管理器中各进程的内存看起来占用并不多情况。

这可能是由于OS为保证服务器性能不限制系统缓存,服务器系统长时间执行I/O,系统文件缓存不断占用物理RAM造成,现在通过限制系统缓存大小来解决。具体可使用微软现已免费工具:Windows Dynamic Cache

Humm that’s a good question when we use Disks and do Read and Write Operations on them at that point there are some I/O (Input and Output Operation) Operations also generated. The Microsoft Windows Dynamic Cache Service will manage the working set size of the Windows System File Cache. For 64 bit systems this service helps to address the problem of excessive cached read I/O that could eventually consume all of physical memory.

By using this Microsoft Windows Dynamic Cache Service we can stabilize the things and initially we need to open a case with Microsoft to get it – but now its good news for us that Microsoft Windows Dynamic Cache Service for Windows Server 2008 R2. It is now freely available to download from the following link: Download Microsoft Windows Dynamic Cache Service for Free

Download:  http://aikitsupport.com/download-microsoft-windows-dynamic-cache-service-free/

具体支持的操作系统官网有详细说明:

Supported Operating System

Windows Server 2003 R2 x64 editions, Windows Server 2003 x64 editions, Windows Server 2008 Datacenter, Windows Server 2008 Enterprise, Windows Server 2008 R2, Windows Server 2008 R2 Datacenter, Windows Server 2008 R2 Enterprise, Windows Server 2008 R2 Standard, Windows Server 2008 Standard, Windows Vista 64-bit Editions Service Pack 1, Windows Vista Enterprise 64-bit edition, Windows Vista Home Basic 64-bit edition, Windows Vista Home Premium 64-bit edition, Windows Vista Ultimate 64-bit edition。 Windows Server 2003, Windows Server 2008, Windows Server 2008 R2, Windows Vista>

Details of the Files is as follows
Version: 1.0.3
Date Published: 2/21/2014
File name: DynCache.zip
File size: 1.4 MB

具体操作可参考解压后的Readme,以下FYI:

1.将解压后的文件夹中Dycache.exe copy到系统盘目录下,%SystemRoot%\System32  
  注意版本问题,DynCache\Retail\AMD64 适应64位普通X86架构系统,IA为安腾系列CPU架构使用的文件,I386对应普通X86架构32位OS。
2.执行脚本,增加Dynamic
Cache Service
sc create DynCache binpath= %SystemRoot%\System32\DynCache.exe start= auto type= own DisplayName= "Dynamic Cache
Service"
3.执行DynCache\DynCache.reg ,导入注册表
4.修改对应注册项参数/值 (MaxSystemCacheMBytes/MinSystemCacheMBytes) 
  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters  
参数说明: 
RegValue:MaxSystemCacheMBytes
Type: REG_DWORD
Values:
0 = Limit to 90% of Physical RAM (default)  --默认虽然表示最大到物理内存90%,实际业务运行到这么大,几乎和无限制没什么区别了。
1-99 = Limit the maximum size of the System File Cache to this percentage of Physical RAM
> 200 = Limit the maximum size of the System File Cache to x Mbytes 
How this works:
This setting is the absolute maximum that the System File Cache’s working set could be set to.  The default is 0, limiting it to 90% of physical RAM with an upper limit of total Physical RAM minus 300 Mbytes.  The lower limit for absolute values is 200 Mbytes
and it must be at least 100 Mbytes greater than the MinSystemCacheMBytes value, which defaults to 100 Mbytes.

RegValue: MinSystemCacheMBytes
Type: REG_DWORD
Values:
0 = 100 Mbytes (default)
x = Limit the minimum size of the System File Cache to x Mbytes
How this works:
This setting is the minimum size of the System File Cache’s working set.  The absolute lower limit is 100 Mbytes.The service does not dynamically change this value.  

 
其他具体参数说明参考附件readme,内容如下(官网可查):
The Microsoft Windows Dynamic Cache Service will manage the working set size of the Windows System File Cache.
 For 64 bit systems this service helps to address the problem of excessive cached read I/O that could eventually consume all of physical memory.  This problem is described in this blog post:
http://blogs.msdn.com/ntdebugging/archive/2007/11/27/too-much-cache.aspx
This service will only run on Windows Server 2008 R2 or earlier versions of Windows.  Do not attempt to run this service on a version of Windows after Windows Server 2008 R2 as it will most likely cause performance problems.
The included source code and compiled executables demonstrate one example of using Microsoft Windows APIs to affect the Windows System File Cache behavior.

Installation
1) Copy DynCache.exe to %SystemRoot%\System32.
2) From a command prompt, run:
 sc create DynCache binpath= %SystemRoot%\System32\DynCache.exe start= auto type= own DisplayName= "Dynamic Cache Service"
3) Import the DynCache.reg registry file.  This registry file contains default settings that you will probably want to modify.

If you wish to uninstall this service, execute the following commands: 
sc stop DynCache
sc delete DynCache

Configuration
The Dynamic Cache Service will monitor the registry for configuration changes.  You do not need to restart the service if you change any of these settings. 
Open Regedit.exe and go to this registry location:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters

RegValue: MaxSystemCacheMBytes
Type: REG_DWORD
Values:
0 = Limit to 90% of Physical RAM (default)
1-99 = Limit the maximum size of the System File Cache to this percentage of Physical RAM
> 200 = Limit the maximum size of the System File Cache to x Mbytes
How this works:
This setting is the absolute maximum that the System File Cache’s working set could be set to.  The default is 0, limiting it to 90% of physical RAM with an upper limit of total Physical RAM minus 300 Mbytes.  The lower limit for absolute values is 200 Mbytes
and it must be at least 100 Mbytes greater than the MinSystemCacheMBytes value, which defaults to 100 Mbytes.

RegValue: MinSystemCacheMBytes
Type: REG_DWORD
Values:
0 = 100 Mbytes (default)
x = Limit the minimum size of the System File Cache to x Mbytes
How this works:
This setting is the minimum size of the System File Cache’s working set.  The absolute lower limit is 100 Mbytes.The service does not dynamically change this value.

RegValue: BackOffMBytesOnLowMemory
Type:  REG_DWORD
Values:
0 = Do not back off on low memory notification
x = Back off x MBytes for each notification.  Keep backing off until the minimum limit is reached.
How this works: 
If this value is set, the Dynamic Cache Service will register for a low memory notification.  If the available memory drops below a threshold, the Dynamic Cache Service will reduce the maximum working set size of the System File Cache by the amount defined
here (in Mbytes).  As long as available memory is below this threshold, this service will continue to reduce the maximum working set size by this amount.  Once available memory is above the threshold, the service will restore the max working set size in increments
of this amount over time.  The default low memory threshold that triggers the notification is 64 MB (if you have at least 2GB of physical RAM).  You can modify the low memory threshold by adding this registry value:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
LowMemoryThreshold (REG_DWORD) – This value is in Mbytes

RegValue: SampleIntervalSecs
Type: REG_DWORD
Values:
0 = Do not monitor processes’ working sets.  Just set the System File Cache limits once and exit.
x = Check the processes’ working sets every x seconds.  Adjust the working set of the System File Cache accordingly.
How this works:
If this is value is defined, this service will use performance monitor counters to check the working sets of active processes.  It will adjust the size of the System File Cache’s working set accordingly.  Setting this value too low could result in more overhead
in monitoring and constant adjusting of the System File Cache’s working set.  Setting this value too high may not allow this service to adjust the working set size of the System File Cache quick enough. The example settings file DynCache.reg sets it to 60
seconds.

RegValue: CacheUpdateThresholdMBytes
Type: REG_DWORD
Values:
0 = Default to 100 Mbytes
x = Update the System File Cache limits when the new calculations change by x Mbytes.
How this works:
This value defines the minimum amount of working set size change that is required before this service will update the size of the System File Cache’s working set.  This setting is used to reduce the frequency of adjusting the System File Cache’s working set
that can be caused by small changes in process working sets.  If you use the default setting of 100 Mbytes, then the process’ working sets will need to increase or decrease by at least 100 Mbytes before this service will update the System File Cache’s working
set size.

RegKeys: <Process Image Name>
Create registry subkeys under the Parameters registry key for each process that you want to back off from.  This service will monitor the working sets of each of these processes and back off the System File Cache’s working set by their combined amount.  If
there are multiple instances of one process, the combined working sets for all instances will be used.  In essence you are trying to prioritizing the working sets for these processes to be higher than the System File Cache’s working set.  The registry file
includes 3 examples: Notepad, Microsoft SQL Server and the System.  Each process can use these additional settings.

RegValue: <Process Image Name>\AdditionalBackoffMBytes
Type: REG_DWORD
Values:
0 = No additional back off bytes for this process
x = Back off an additional x Mbytes if this process is running
How this works:
If this value is defined and this process is currently active this service will back off the process’s working set plus this additional amount.  You can use this setting as additional slack space for only when this process is running.  Multiple instances of
this process have no affect on this amount.  It is only used for the first instance of this process.

RegValue: <Process Image Name>\AdditionalBackOffCounter
Type: REG_SZ
Value:
<formatted counter string> = Whatever this counter value is, back off by that amount.
How this works:
This string needs to be a correctly formatted performance monitor string.  Refer to the SQL Server sample for an example of using an additional counter to monitor.  If this process is active, this service will use this additional counter.

SQL Server Example:
SQL Server’s process’s working set does not include the size of the database that is in physical RAM.  The SQL Server performance counter exposes a different counter that keeps track of database memory usage.  That counter is: "\SQLServer:Memory Manager\Total
Server Memory (KB)".  If this counter is defined as an AdditionalBackOffCounter for sqlservr (as provided in the default registry file), then this service will back off from SQL Server’s working set and the working set of its database.  If you want to prioritize
SQL’s (or similar application) working set over the System File Cache’s working set then you should use this counter to properly account for the memory usage of this process.
Since this service is set to start automatically and it is very light weight, it will probably start before SQL Server.  The service will attempt to query the SQL counter, but the SQL may not be fully started.  The SQL counter may return invalid numbers.  If
you use this service to monitor SQL Server, then you need to set this service’s dependency on SQL Server’s service.  This way the SQL counter will be able to query the SQL service and return valid numbers.  To set a dependency on the SQL service, go to the
following registry key and add this registry value:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters
RegValue: DependOnService
Type: REG_MULTI_SZ
Value:
MSSQLSERVER

Source Code
The source code for the Microsoft Windows Dynamic Cache Service is provided along with the compiled binaries.  In order to build this project, it is recommended that you install both the Windows Driver Kit (WDK) and the Windows Software Development Kit (SDK).
 Use the WDK build environment and add the following environment variables:
PSDK_INC_PATH – Set this to the location of the include files for the Windows SDK.
PSDK_LIB_PATH – Set this to the location of the libraries for the Windows SDK.
This project requires the Windows SDK because it uses the Performance Data Helper (PDH) library to collect performance counter data.

Troubleshooting/Verification
The debug build of this service includes debug logging of what this service is doing.  Copy the debug build of this service to your System32 folder and use DebugView (from www.sysinternals.com) to see what this service is doing.

Disclaimer
This service is experimental.  The code and compiled binary are provided as a sample.  Anyone is free to use this code in their own solution.  Please note that you may experience some performance side effects while using this service.  It cannot possibly address
all usage scenarios.  There may be some edge usage scenarios that are negatively impacted by this service.  The service only attempts to improve the situation given the current limitations.  Please report any bugs or observations to the blog (above).  While
we may not be able to fix every usage problem, we will try to offer best effort support.
 
Side Effects may include
Cache page churn - If the System File Cache's working set is too low and there is sustained cached read I/O, the memory manager may not be able to properly age pages.  When forced to remove some pages in order to make room for new cache pages, the memory manager
may inadvertently remove the wrong pages.  This could result in cached page churn and decreased disk performance for all applications.

fromhttps://blog.csdn.net/elsaleo/article/details/52997273?utm_source=copy

windows2008系统缓存修改的更多相关文章

  1. 设置windows2008系统缓存大小限制,解决服务器运行久了因物理内存耗尽出僵死(提升权限后,使用SetSystemFileCacheSize API函数,并将此做成了一个Service)

    声明: 找到服务器僵死的原因了,原因是虚拟内存设置小于物理内存. 只要虚拟内存设置为系统默认大小就不会出生僵死的现象了. 当时因为服务器内存48G,系统默认虚拟内存大小也是48G, 觉得太占硬盘空间, ...

  2. C# ASP.NET系统缓存全解析

    原文:http://blog.csdn.net/wyxhd2008/article/details/8076105 目录(?)[-] 系统缓存的概述 页面输出缓存 页面局部缓存 文件缓存依赖 数据库缓 ...

  3. Mybatis缓存(1)--------系统缓存及简单配置介绍

    前言 Mybatis的缓存主要有两种: 系统缓存,也就是我们一级缓存与二级缓存: 自定义的缓存,比如Redis.Enhance等,需要额外的单独配置与实现,具体日后主要学习介绍. 在这里主要记录系统缓 ...

  4. C# 嵌入dll 动软代码生成器基础使用 系统缓存全解析 .NET开发中的事务处理大比拼 C#之数据类型学习 【基于EF Core的Code First模式的DotNetCore快速开发框架】完成对DB First代码生成的支持 基于EF Core的Code First模式的DotNetCore快速开发框架 【懒人有道】在asp.net core中实现程序集注入

    C# 嵌入dll   在很多时候我们在生成C#exe文件时,如果在工程里调用了dll文件时,那么如果不加以处理的话在生成的exe文件运行时需要连同这个dll一起转移,相比于一个单独干净的exe,这种形 ...

  5. 性能分析(7)- 未利用系统缓存导致 I/O 缓慢案例

    性能分析小案例系列,可以通过下面链接查看哦 https://www.cnblogs.com/poloyy/category/1814570.html 前提 前面有学到 Buffer 和 Cache 的 ...

  6. linux系统下修改文件夹目录权限

    linux系统下修改文件夹目录权限 文件夹权限问题 Linux.Fedora.Ubuntu修改文件.文件夹权限的方法差不多.很多人开始接触Linux时都很头痛Linux的文件权限问题.这里告诉大家如何 ...

  7. C#系统缓存全解析(转载)

    C#系统缓存全解析 对各种缓存的应用场景和方法做了很详尽的解读,这里推荐一下 转载地址:http://blog.csdn.net/wyxhd2008/article/details/8076105

  8. Windows2008系统忘记密码的解决方法

    网上转载的,忘记密码不用发愁了.   windows2008系统忘记密码的解决方法: 利用放大镜的漏洞来重设密码 首先用系统盘来引导 选择修复计算机 然后打开命令提示符:先备份放大镜,然后用CMD替换 ...

  9. linux系统缓存机制

    http://my.oschina.net/lenglingx/blog/425258 1.缓存机制 为了提高文件系统性能,内核利用一部分物理内存分配出缓冲区,用于缓存系统操作和数据文件,当内核收到读 ...

随机推荐

  1. Ubuntu下一个好用的终端

    在终端下输入: sudo apt-get install terminator 快捷键: shift+ctrl+e          在当前窗口右侧新开一个窗口 shift+ctrl+w        ...

  2. python-基础-文件

    一.文件操作 打开文件时,需要指定文件路径和以何等方式打开文件, 对文件操作流程 打开文件,得到文件句柄并赋值给一个变量 通过句柄对文件进行操作 关闭文件 打开文件的模式有: r ,只读模式[默认模式 ...

  3. 数字int字符串str(深入学习)

    数字int字符串str 查看一个对象的类 如:如查看对象变量a是什么类          用到函数type(),函数值是要查看的对象变量 1 #!/usr/bin/env python 2 # -*- ...

  4. hdu3642 Get The Treasury 线段树--扫描线

    Jack knows that there is a great underground treasury in a secret region. And he has a special devic ...

  5. diskcache

    DiskCache: Disk Backed Cache DiskCache is an Apache2 licensed disk and file backed cache library, wr ...

  6. sql表连接方式

    表连接有几种? sql表连接分成外连接.内连接和交叉连接.   一.外连接 概述: 外连接包括三种,分别是左外连接.右外连接.全外连接. 对应的sql关键字:LEFT/RIGHT/FULL OUTER ...

  7. quicklink 基本使用

    原理 使用可见性以及预取数据,同时充分利用浏览器的空闲时间,主要是解析href 以通过代码的选项指定需要加载的数据,当然其中 也添加了好多灵活的控制参数,方便我们使用,而且代码很小,压缩之后也就1kb ...

  8. 05机器学习实战之Logistic 回归scikit-learn实现

    https://blog.csdn.net/zengxiantao1994/article/details/72787849似然函数 原理:极大似然估计是建立在极大似然原理的基础上的一个统计方法,是概 ...

  9. Go语言实战 (William,Kennedy 等著)

    第1章 关于Go语言的介绍 (已看) 1.1 用Go解决现代编程难题 1.1.1 开发速度 1.1.2 并发 1. goroutine 2. 通道 1.1.3 Go语言的类型系统 1. 类型简单 2. ...

  10. e的故事.一个常数的传奇 (Eli Maor 著)

    第1章 约翰*纳皮尔 (已看) 第2章 认知 (已看) 对数运算 第3章 财务问题 (已看) 第4章 若极限存在,则达之 (已看) 一些与e有关的奇妙的数 第5章 发现微积分的先驱 (已看) 第6章 ...