内存

原创 2004年08月23日 20:55:00

SetProcessWorkingSetSize

The SetProcessWorkingSetSize function sets the minimum and maximum working set sizes for the specified process.


BOOL SetProcessWorkingSetSize(
  HANDLE hProcess,
  SIZE_T dwMinimumWorkingSetSize,
  SIZE_T dwMaximumWorkingSetSize
);

Parameters
hProcess
[in] Handle to the process whose working set sizes is to be set.
The handle must have the PROCESS_SET_QUOTA access right. For more information, see Process Security and Access Rights.

dwMinimumWorkingSetSize
[in] Minimum working set size for the process, in bytes. The virtual memory manager attempts to keep at least this much memory resident in the process whenever the process is active.
If both dwMinimumWorkingSetSize and dwMaximumWorkingSetSize have the value -1, the function temporarily trims the working set of the specified process to zero. This essentially swaps the process out of physical RAM memory.

dwMaximumWorkingSetSize
[in] Maximum working set size for the process, in bytes. The virtual memory manager attempts to keep no more than this much memory resident in the process whenever the process is active and memory is in short supply.
If both dwMinimumWorkingSetSize and dwMaximumWorkingSetSize have the value -1, the function temporarily trims the working set of the specified process to zero. This essentially swaps the process out of physical RAM memory.

Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. Call GetLastError to obtain extended error information.

Remarks
The working set of a process is the set of memory pages currently visible to the process in physical RAM memory. These pages are resident and available for an application to use without triggering a page fault. The minimum and maximum working set sizes affect the virtual memory paging behavior of a process.

The working set of the specified process can be emptied by specifying the value -1 for both the minimum and maximum working set sizes.

If the values of either dwMinimumWorkingSetSize or dwMaximumWorkingSetSize are greater than the process' current working set sizes, the specified process must have the SE_INC_BASE_PRIORITY_NAME privilege. Users in the Administrators and Power Users groups generally have this privilege. For more information about security privileges, see Privileges.

The operating system allocates working set sizes on a first-come, first-served basis. For example, if an application successfully sets 40 megabytes as its minimum working set size on a 64-megabyte system, and a second application requests a 40-megabyte working set size, the operating system denies the second application's request.

Using the SetProcessWorkingSetSize function to set an application's minimum and maximum working set sizes does not guarantee that the requested memory will be reserved, or that it will remain resident at all times. When the application is idle, or a low-memory situation causes a demand for memory, the operating system can reduce the application's working set. An application can use the VirtualLock function to lock ranges of the application's virtual address space in memory; however, that can potentially degrade the performance of the system.

When you increase the working set size of an application, you are taking away physical memory from the rest of the system. This can degrade the performance of other applications and the system as a whole. It can also lead to failures of operations that require physical memory to be present; for example, creating processes, threads, and kernel pool. Thus, you must use the SetProcessWorkingSetSize function carefully. You must always consider the performance of the whole system when you are designing an application.

Requirements
Client: Included in Windows XP, Windows 2000 Professional, and Windows NT Workstation 3.5 and later.
Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server 3.5 and later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.


See Also
Processes and Threads Overview, Process and Thread Functions, GetProcessWorkingSetSize, VirtualLock

STM32 DMA->内存到内存

基于STM32 F401 Discovery板: DMA2在AHB1总线上 步骤一:使能DMA #define DMA_STREAM_CLOCK RCC_AHB1...
  • XiaoXiaoPengBo
  • XiaoXiaoPengBo
  • 2016年02月03日 15:22
  • 2655

Android内存优化之内存缓存

前言: 上面两篇博客已经讲了图片的基本知识和图片的加载方法及优化,所有的这些优化都是为了避免应用出现OOM这个问题。一个好的应用程序不仅要健壮不能出错还要方便用户使用,对于用户来说你的应用不仅要美观...
  • lihui130135
  • lihui130135
  • 2015年06月16日 18:28
  • 2392

从内存管理、内存泄漏、内存回收探讨C++内存管理

原文地址:http://www.cr173.com/html/18898_all.html 文章很棒,忍不住转载了 内存管理是C++最令人切齿痛恨的问题,也是C++最有争议的问题,C++高...
  • itas109
  • itas109
  • 2014年10月03日 19:34
  • 1509

动态内存+BFS

  • 2018年01月15日 18:18
  • 12KB
  • 下载

最新volatility内存取证软件(windows版)

  • 2018年01月10日 21:47
  • 14.84MB
  • 下载

基于stm32的字符识别(卡在内存上了)

  • 2018年01月17日 10:39
  • 11.72MB
  • 下载

内存分析工具MAT

  • 2018年01月09日 18:16
  • 64.6MB
  • 下载

内存技术平台(SAP-HANA)深度剖析

  • 2018年01月07日 09:48
  • 5.24MB
  • 下载

检查系统io cup 磁盘 内存 以及tomcat是否正常运行脚本

  • 2018年01月09日 09:52
  • 5KB
  • 下载

LINUX部署tomcat内存溢出解决方案.txt

  • 2018年01月05日 22:55
  • 414B
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:内存
举报原因:
原因补充:

(最多只允许输入30个字)