jnlyu
狐狸大王
狐狸大王
  • UID10304
  • 注册日期2005-12-04
  • 最后登录2015-06-17
  • 发帖数304
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
15楼#
发布于:2010-04-20 15:49
idragonet:这个是内存伪释放,无用的。回到原帖

我也一直認為像這樣的釋放是多餘的,
但也找不到比較科學的證據證明無效,
或許只能請微軟核心開發人員來解釋了。
AppNavi手机应用官方微博 介绍最新的密室逃脱游戏!
http://weibo.com/appnavi
idragonet
千年狐狸
千年狐狸
  • UID15658
  • 注册日期2006-11-12
  • 最后登录2017-11-15
  • 发帖数2642
  • 经验162枚
  • 威望1点
  • 贡献值74点
  • 好评度118点
  • 社区居民
16楼#
发布于:2010-04-20 15:49


[quote]
这是从MSDN摘下的原话:
  
Using the SetProcessWorkingSetSize function to set an applications 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 applications working set. An application can use the VirtualLock function to lock ranges of the applications virtual address space in memory; however, that can potentially degrade the performance of the system.
  
使用这个函数来设置应用程序最小和最大的运行空间,只会保留需要的内存。当应用程序被闲置或系统内存太低时,操作系统会自动调用这个机制来设置应用程序的内存。应用程序也可以使用  VirtualLock  来锁住一定范围的内存不被系统释放。
  
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.
  
当你加大运行空间给应用程序,你能够得到的物理内存取决于系统,这会造成其他应用程序降低性能或系统总体降低性能,这也可能导致请求物理内存的操作失败,例如:建立 进程,线程,内核池,就必须小心的使用该函数。
  
========================
  
事实上,使用该函数并不能提高什么性能,也不会真的节省内存。
  
因为他只是暂时的将应用程序占用的内存移至虚拟内存,一旦,应用程序被激活或者有操作请求时,这些内存又会被重新占用。如果你强制使用该方法来 设置程序占用的内存,那么可能在一定程度上反而会降低系统性能,因为系统需要频繁的进行内存和硬盘间的页面交换。
  
  
BOOL SetProcessWorkingSetSize(
   HANDLE hProcess,
   SIZE_T dwMinimumWorkingSetSize,
   SIZE_T dwMaximumWorkingSetSize
);
  
  
将 2个  SIZE_T  参数设置为 -1 ,即可以使进程使用的内存交换到虚拟内存,只保留一小部分代码
  
而桌面日历秀 之所以能够 总是保持 最小内存,是因为使用了定时器,不停的进行该操作,,所以性能可想而知,虽然换来了小内存的假象,对系统来说确实灾难。
  
当然,该函数也并非无一是处,
  
1 。当我们的应用程序刚刚加载完成时,可以使用该操作一次,来将加载过程不需要的代码放到虚拟内存,这样,程序加载完毕后,保持较大的可用内存。VB尤甚
  
2.程序运行到一定时间后或程序将要被闲置时,可以使用该命令来交换占用的内存到虚拟内存。
skyatcn
小狐狸
小狐狸
  • UID23507
  • 注册日期2008-04-01
  • 最后登录2012-06-03
  • 发帖数13
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
17楼#
发布于:2010-04-20 15:49
我只有2G的内存,firefox常常飙到500~700M,哪怕你关闭了所有的标签页
上一页 下一页
游客

返回顶部