Without -Xmx, you basically get -Xmx64m, and the VM will NOT attempt to allocate more than that. Instead, it'll first fire up the collector and when that fails, it'll start throwing OOMEs. Though, if you're getting near the limit, first the VM will slow down to a crawl (due to repeated calls to the garbage collector, as the practical memory space is reduced to an ever smaller amount of memory, forcing lots of GC cycles), and then it'll start throwing OOMEs. (I'm not sure if 64m is still the standard if you don't add an -Xmx, though).
-Xmx will increase the point at which the VM stops allocating memory and instead uses GC and OOME. -Xms, well, it _sounds_ like this simply forces actually allocing all that memory right away instead of doing that on the fly, but this is where I get a little fuzzy. Normally -Xmx will get the job done. On Oct 19, 11:46 pm, Mike Hopper <[email protected]> wrote: > I've been doing Java development for many years but sometimes > something surprises me. A coworker was explaining to me that many JVMs > allocate all of the memory specified by the -Xmx parameter at > application startup time. He said that this was an optimization > feature and that the JVM needs to ensure that it gets a contiguous > address space for its heap at startup. Some google searches confirmed > that this is the case for the IBM JVM. > > One reason this discussion came up is because we could not start a web > app with -Xmx=1gb (even though 2gb were free) because (according to > his explanation) the OS could not find 1gb of contiguous memory. He > resolved the issue by rebooting the machine (thus defragging the > physical memory). > > Anyone here familiar with this. It seemed strange to me because (a) > why have both Xms and Xmx settings if the JVM is just going to grab > all the memory it will ever need at startup? (b) Eclipse, which is a > Java app, seems to grow and shrink its memory footprint throughout the > day (at least on Windows). Perhaps different JVMs have different > strategies for grabbing memory from OS. > > Any insight would be appreciated. > > Mike -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
