I am running an application on a Windows XP machine. The application has massive tables in memory. Though the machine has approximately 2GB, the JVM runs out of memory. (The application is started with -Xm2GB.)
Is there a restriction in JVM about maximum size of memory it can use? Or machine/OS restricts the memory size? From my investigation a XP process can acquire 2GB.
There may be some limit to -Xmx based on your machine. However if you exceed the limit, you should get a clear error message, like
$ java -Xmx2G Test Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.
I think that it's more likely that your program is really using 2G of memory. One simple way to verify this is to run with the -verbose:gc option, which prints out messages for you about how much memory there is, and what the garbage collector's doing. Or if you're using JDK 5+, you could use JConsole. If you really are using that much memory, you'll have to figure out where it's coming from. Maybe there's a memory leak you can plug, or maybe there's a different algorithm you can use to require less memory.
The XP does not allow to use 2gb memory though available. SOlaris & some Linux distributions are allowing that much of memory. In XP, as per my knowledge , only 1300 MB memory is allowed to use. So better try with some less amount of memory parameter & go on increaing gradually. Ex -Xmx256M or -Xmx512M