强制将内存释放到操作系统 [英] Force memory release to the OS

查看:106
本文介绍了强制将内存释放到操作系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要约20 MB内存的应用程序。在很少使用的算法中,它(std :: vector)临时分配250 MB。解除分配后,系统监视器仍显示此用法。如何将内存释放回系统?

I have an app that takes about 20 MB of ram. In an seldom used algorithm it (std::vector) temporarily allocates 250 MB. After the deallocation the systemmonitor still shows this usage. How can I release the memory back to the system?

推荐答案

您不能也不应这样做。

虚拟内存分配很复杂,仅通过在系统监视器中查看一个数字就无法充分理解。看起来进程似乎在使用比其应有的内存更多的内存,但这只是虚拟内存寻址工作方式的伪像。

Virtual memory allocation is complicated, and cannot be sufficiently understood by simply watching a number in System Monitor. It may appear as if a process is using more memory than it should, but this is just an artefact of the way virtual memory addressing works.

请放心,如果您有

这里唯一可采取的实际操作是停止使用系统监视器,就好像它已被释放一样。准确测量您的进程正在使用的物理RAM!

The only real actionable point here is to stop using System Monitor as if it were an accurate measure of physical RAM in use by your process!

这篇关于强制将内存释放到操作系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆