The moose likes Performance and the fly likes Maximum allowed for JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Maximum allowed for JVM" Watch "Maximum allowed for JVM" New topic

Maximum allowed for JVM

Sushil Sharma

Joined: Nov 02, 2006
Posts: 22
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.

I would appreciate your help .
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
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.

"I'm not back." - Bill Harding, Twister
prasad kulkarni
Ranch Hand

Joined: Mar 19, 2006
Posts: 66
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

scjp, scwcd
I agree. Here's the link:
subject: Maximum allowed for JVM