Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tools to view/solve Windows XP memory fragmentation

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:

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

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.

like image 506
SteveDonie Avatar asked Sep 19 '08 16:09

SteveDonie


People also ask

How to detect heap fragmentation?

Find the largest free block size in the heap (not a block that is in use). Find the total free space in the heap. If the largest free block size is small compared to the total free size then you probably have a fragmentation problem.

What is low fragmentation heap?

The low-fragmentation heap (LFH) helps to reduce heap fragmentation. The LFH is not a separate heap. Instead, it is a policy that applications can enable for their heaps. When the LFH is enabled, the system allocates memory in certain predetermined sizes.


1 Answers

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.

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

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.

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...

like image 157
John Gardner Avatar answered Oct 20 '22 00:10

John Gardner