Win32/MFC:如何查找可用的可用内存(RAM)? [英] Win32/MFC: How to find free memory (RAM) available?

查看:90
本文介绍了Win32/MFC:如何查找可用的可用内存(RAM)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何建议/提示/链接/教程将不胜感激! :)

Any suggestions/hints/links/tutorials would be appreciated! :)

推荐答案

确实没有答案.在正常情况下,操作系统基本上会在系统上的所有内存中保留某物.基本上,一旦将某些内容读入内存,它将在内存中保留它的副本,直到其他内容需要内存,以便第一个被踢出.有许多函数可以为您提供有关内存的信息,但是它们中的任何一个都没有尝试真正返回完全未使用的内存量.我知道的最接近的是 GlobalMemoryStatusEx ,它会返回一个数字,表示可用的内存量.

There really is no answer to this. Under normal circumstances, the OS will keep something in essentially all the memory on the system. Basically, once it's read something into memory, it'll keep a copy of it in memory until something else needs memory so the first one gets kicked out. There are a number of functions that can get you information about memory, but none of them even attempts to really return an amount of memory that's completely unused. The closest of which I'm aware is GlobalMemoryStatusEx, which does return a number for the amount of memory that's available.

这意味着该内存中的当前内容同时在内存中,因此可以丢弃内存中的副本,而不必先将其写入磁盘.例如,如果您运行一个程序,大多数代码将保留在内存中(直到其他人想要内存),以防万一您决定再次运行它.由于它只是磁盘上程序的副本,因此可以将其丢弃,并在需要时从磁盘重新加载.(如果有必要).

That means whatever is currently in that memory is currently both in memory and on disk, so the copy in memory can be thrown away without having to write it to disk first. For example, if you ran a program, most of is code will stay in memory (until something else wants memory), in case you decide to run it again. Since it's just a copy of the program on disk, it can be thrown away, and (if necessary) reloaded from disk when needed.

如果您想了解更多详细信息,可以使用 VirtualQueryEx 来获取它-但是它通常会使您信息超载,告诉您给定进程中使用的每个内存块,而不是给出一个很好的简单数字,表示"x字节可用"

If you want more detail, you can use things like VirtualQueryEx to get it -- but it'll usually overload you with information, telling you about each block of memory used in a given process, instead of giving a nice, simple number saying "x bytes free".

这篇关于Win32/MFC:如何查找可用的可用内存(RAM)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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