如何在 64 位 Windows 7 上检索 RAM
我在具有 24GB 内存的 64 位 Windows Vista 上安装了 Java 桌面应用程序。我的程序只找到 24GB 中的 4 个。我正在使用 RAM
wmic computersystem get TotalPhysicalMemory /format:list
如果失败(如果他们没有 WMI)我使用
com.sun.management.OperatingSystemMXBean bean = (com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean();
long ram = (long) bean.getTotalPhysicalMemorySize();
因为我无权访问 PC 我无法运行测试来确认使用了哪种方法,但我几乎可以肯定该机器确实有 WMI。
我怀疑我正在运行 32 位 WMI,它可能有 4GB 限制。如何运行 64 位 WMI?
I have a Java Desktop App installed on a 64bit Windows Vista with 24GB of ram. My program is only finding 4 of the 24GB. I am getting the RAM using
wmic computersystem get TotalPhysicalMemory /format:list
And if that fails (in case they don't have WMI) I use
com.sun.management.OperatingSystemMXBean bean = (com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean();
long ram = (long) bean.getTotalPhysicalMemorySize();
Because I don't have access to the PC I was not able to run tests to confirm which method is used but I am almost certain that the machine does have WMI.
I am suspecting that I am running a 32bit WMI which is likely to have a 4GB limit. How do I run a 64bit WMI?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我猜你使用的是 32 位 JRE 而不是 64 位。我们可以看到
java -version
的输出吗?I'm guessing you're using a 32-bit JRE instead of 64-bit. Can we see the output of
java -version
?Windows WOW64 层的一部分是尽可能完美地模拟 32 位环境 .否则它就是一个糟糕的模拟器。
32 位应用程序的 WMI 将仅返回 32 位应用程序以前所期望的内容。例如,假设程序尝试使用 32 位整数存储系统内存的字节数。好吧,如果 WMI 说的是实话并返回 24 GB,那么程序会在尝试将该数字填充到 32 位整数中时崩溃(或者如果未检查操作则给出不正确的结果)。
推荐的解决方案是使用 64 位 JRE 并让您的程序在 64 位中运行。
Part of the Windows WOW64 layer is to emulate a 32-bit environment as perfectly as possible. Otherwise it's a lousy emulator.
WMI for a 32-bit application will only return what a 32-bit application would previously have been able to expect. For example, assuming a program tried to store the number of bytes of system memory using a 32-bit integer. Well, if WMI told the truth and returned 24 GB, then the program would crash trying to stuff that number in a 32-bit integer (or give an incorrect result if the operation isn't checked).
The recommended solution is to use the 64-bit JRE and have your program run in 64-bit.
如果您知道自己位于 64 位系统上的 32 位 JRE 中,则可以按如下方式运行 64 位 WMIC:
请注意,此命令无法在 64 位 JRE 或 32 位 JRE 上运行位系统,所以你需要先弄清楚你所处的环境。
If you know that you're inside a 32-bit JRE on a 64-bit system, you can run the 64-bit WMIC as follows:
Note that this command won't work from a 64-bit JRE, or on a 32-bit system, so you need to figure out which environment you're in first.