如何从 Windows 命令行检索可用 RAM?
Windows 或第三方程序中是否有命令行实用程序可以检索计算机上的可用 RAM? (因为我不相信这可以在纯JAVA中完成,因为它是在虚拟机中运行,并且已经预设/分配了RAM)?
Is there a command line utility within Windows or third-party program that can retrieve available RAM on a machine? (Since I don't believe this can be done in pure JAVA, since it is run within a virtual machine, that has preset / allocated RAM)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
systeminfo
是一个命令,将输出系统信息,包括可用内存systeminfo
is a command that will output system information, including available memory使用
wmiccomputersystem获取TotalPhysicalMemory
。例如:Use
wmic computersystem get TotalPhysicalMemory
. E.g.:请注意,不是其他地方建议的
TotalPhysicalMemory
Note not
TotalPhysicalMemory
as suggested elsewhereSysSnternals 提供了大量有用的低级工具。
psinfo
可能是最有用的。我使用了以下 psinfo 开关:
示例输出如下:
There is a whole bunch of useful low level tools from SysSnternals.
And
psinfo
may be the most useful.I used the following psinfo switches:
Sample output is this:
有点旧,但我想知道类似的。只是添加我遇到的解决方案,因为 IMO 最好的答案来自 Everardo w/ 物理内存
这让我更深入地研究 wmic...请记住,空闲物理内存不是要查看的类型。
wmic OS get FreePhysicalMemory,FreeVirtualMemory,FreeSpaceInPagingFiles /VALUE
这会返回类似...
Bit old but I wanted to know similar. Just adding the solution I came across since IMO the best answer came from Everardo w/ Physical Memory
This lead me to look deeper into wmic... Keep in mind Free Physical Memory is not the type to look at.
wmic OS get FreePhysicalMemory,FreeVirtualMemory,FreeSpaceInPagingFiles /VALUE
This returns something like...
发布的 wmic 命令的 Powershell 版本:
Powershell version of the posted wmic commands:
这不能在纯java中完成。但是你可以使用java运行外部程序并得到结果。
This cannot be done in pure java. But you can run external programs using java and get the result.
尝试内存日志。它完美而快速地完成了这项工作。
通过多个镜像之一下载,例如这个:MemLog 的 SoftPedia 页面 .
(MemLog 的作者有一个网站。但有时会关闭。回溯机快照 此处。)
示例输出:
878956544
是可用内存Try MemLog. It does the job perfectly and quickly.
Download via one of many mirrors, e.g. this one: SoftPedia page for MemLog.
(MemLog's author has a web site. But this is down some times. Wayback machine snapshot here.)
Example output:
878956544
being the free memory实际上,这是一个纯粹的
Java
解决方案:Here is a pure
Java
solution actually:如果您在 Java 程序中需要此功能,您可能需要查看 sigar API:http:// /www.hyperic.com/products/sigar
实际上,我知道这不是问题的答案,而是一个提示,这样您就不必重新发明轮子。
Just in case you need this functionality in a Java program, you might want to look at the sigar API: http://www.hyperic.com/products/sigar
Actually, this is no answer to the question, I know, but a hint so you don't have to reinvent the wheel.
由于问题是关于窗口命令行中的可用 RAM,因此答案如下:
您可以使用全局命令获取有关内存和其他内容所需的所有信息。
之后,您只需使用 get yourFilterName 添加过滤器
希望这会有所帮助;)
As the question was about the available RAM form a window commande line, here is the answer :
you can get all the information you need about memory and other things using the global commande
After that you'll only have the add a filter using get yourFilterName
Hope this will help ;)
您可以通过管道将“systeminfo”传递给 grep
结果如下:
You can pipe "systeminfo" to grep
The result will be as follow: