查看/解决 Windows XP 内存碎片的工具
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/103622/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tools to view/solve Windows XP memory fragmentation
提问by SteveDonie
We have a java program that requires a large amount of heap space - we start it with (among other command line arguments) the argument -Xmx1500m, which specifies a maximum heap space of 1500 MB. When starting this program on a Windows XP box that has been freshly rebooted, it will start and run without issues. But if the program has run several times, the computer has been up for a while, etc., when it tries to start I get this error:
我们有一个需要大量堆空间的 java 程序 - 我们以(在其他命令行参数中)参数 -Xmx1500m 开始它,它指定了 1500 MB 的最大堆空间。在刚刚重新启动的 Windows XP 机器上启动该程序时,它可以毫无问题地启动和运行。但是如果程序运行了几次,计算机已经启动了一段时间等等,当它尝试启动时我得到这个错误:
Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.
I suspect that Windows itself is suffering from memory fragmentation, but I don't know how to confirm this suspicion. At the time that this happens, Task manager and sysinternals procexp report 2000MB free memory. I have looked at this question related to internal fragmentation
我怀疑 Windows 本身存在内存碎片问题,但我不知道如何确认这种怀疑。发生这种情况时,任务管理器和 sysinternals procexp 报告有 2000MB 可用内存。我看过这个与内部碎片相关的问题
So the first question is, How do I confirm my suspicion? The second question is, if my suspicions are correct, does anyone know of any tools to solve this problem? I've looked around quite a bit, but I haven't found anything that helps, other than periodic reboots of the machine.
所以第一个问题是,我如何确认我的怀疑?第二个问题是,如果我的怀疑是正确的,有没有人知道解决这个问题的任何工具?我环顾四周,但除了定期重新启动机器之外,我没有发现任何有用的东西。
ps - changing operating systems is also not currently a viable option.
ps - 改变操作系统目前也不是一个可行的选择。
采纳答案by John Gardner
Agree with Torlack, a lot of this is because other DLLs are getting loaded and go into certain spots, breaking up the amount of memory you can get for the VM in one big chunk.
同意 Torlack,其中很大一部分是因为其他 DLL 正在加载并进入某些位置,将您可以为 VM 获得的内存量分成一大块。
You can do some work on WinXP if you have more than 3G of memory to get some of the windows stuff moved around, look up PAE here: http://www.microsoft.com/whdc/system/platform/server/PAE/PAEdrv.mspx
如果你有超过 3G 的内存来移动一些 Windows 的东西,你可以在 WinXP 上做一些工作,在这里查找 PAE:http: //www.microsoft.com/whdc/system/platform/server/PAE/ PAE驱动文件
Your best bet, if you really need more than 1.2G of memory for your java app, is to look at 64 bit windows or linux or OSX. If you're using any kind of native libraries with your app you'll have to recompile them for 64 bit, but its going to be a lot easier than trying to rebase dlls and stuff to maximize the memory you can get on 32 bit windows.
如果您的 java 应用程序确实需要超过 1.2G 的内存,最好的选择是查看 64 位 Windows 或 linux 或 OSX。如果您在应用程序中使用任何类型的本机库,则必须为 64 位重新编译它们,但这比尝试重新设置 dll 和其他内容以最大化您在 32 位 Windows 上可以获得的内存要容易得多.
Another option would be to split your program up into multiple VMs and have them communicate with eachother via RMI or messaging or something. That way each VM can have some subset of the memory you need. Without knowing what your app does, i'm not sure that this will help in any way, though...
另一种选择是将您的程序拆分为多个 VM,并让它们通过 RMI 或消息传递或其他方式相互通信。这样,每个 VM 都可以拥有您需要的某些内存子集。在不知道您的应用程序做什么的情况下,我不确定这是否会有所帮助,但...
回答by Torlack
Unless you are running out of page file space, this issue isn't that the computer is running out of memory. The whole point of virtual memory is to allow the processes to use more virtual memory than is physically available.
除非页面文件空间不足,否则这个问题不是计算机内存不足。虚拟内存的全部意义在于允许进程使用比物理可用内存更多的虚拟内存。
Not knowing how the JVM handles the heap, it is a bit hard to say exactly what the problem is, but one of the common issues is that there isn't enough contiguous free address space available in your process to allow the heap to be extended. Why this would be a problem after the machine has been running a while is a bit confusing.
不知道 JVM 如何处理堆,很难说到底是什么问题,但常见问题之一是您的进程中没有足够的连续空闲地址空间来允许扩展堆. 为什么这会在机器运行一段时间后出现问题有点令人困惑。
I've been working on a similar problem at work. I have found that running the program using WinDBG and using the "!address" and "!address -summary" commands have been invaluable in tracking down why a processes' virtual address space has become fragmented. You can also try running the program after reboot and using the "!address" command to take a picture of the address space and then do the same when the program no longer runs. This might clue you in on the problem. Maybe something simple as an extra DLL getting loading might cause the problem.
我一直在研究工作中的类似问题。我发现使用 WinDBG 运行程序并使用“!address”和“!address -summary”命令对于追踪进程的虚拟地址空间为何变得碎片化非常有用。您也可以尝试在重新启动后运行该程序并使用“!address”命令拍摄地址空间的图片,然后在程序不再运行时执行相同的操作。这可能会提示您解决问题。也许一些简单的事情,比如加载额外的 DLL 可能会导致问题。
回答by SteveDonie
I suspect that the problem is Windows memory fragmentation. There is another question here on StackOverflow called Java Maximum Memory on Windows XPthat mentions using Process Explorer to look at where DLLs are mapped into memory, and then to address the problem by rebasing the DLLs so that load into memory in a more compact way.
我怀疑问题是 Windows 内存碎片。StackOverflow 上还有另一个问题,称为Windows XP 上的 Java 最大内存,其中提到使用进程资源管理器查看 DLL 映射到内存的位置,然后通过重新设置 DLL 的基础来解决问题,以便以更紧凑的方式加载到内存中。
回答by jey burrows
Use vmmap from Microsoft's SysInternals tools to view the fragmentation of the virtual address space, and identify what's breaking up the space
使用微软 SysInternals 工具中的 vmmap 查看虚拟地址空间的碎片,并确定是什么打破了空间
回答by kulakli
Using Minimem (http://minimem.kerkia.net/) for that application might fix your problem. However, I'm not sure this is the answer you are looking for. I hope it helps.
为该应用程序使用 Minimem ( http://minimem.kerkia.net/) 可能会解决您的问题。但是,我不确定这是您正在寻找的答案。我希望它有帮助。
回答by Okami
Maybe you should consider to start the program and reserving the memory and not end the VM after each run. Look for different GC options and release your objects.
也许您应该考虑启动程序并保留内存,而不是在每次运行后结束 VM。寻找不同的 GC 选项并释放您的对象。