1

Possible Duplicate:
How is the default java heap size determined?

Im curious what happens if I do not specify a -Xms for initial JVM heap size with Java?

Currently I have -Xms256m and -Xmx512m but this gives me an error on my server :

Failed to create JVM, return code is:-1

I believe the JVM is having trouble getting 256MB of contiguous memory with a 256m starting point. Prior to today we only had a -Xmx256m setting but had some processes that were running out of memory.

Can the JVM function if I remove the -Xms setting and just leave the -Xmx512m'? What does the heap start with?

How does it acquire contiguous memory if no starting heap is declared?

Community
  • 1
  • 1
ProfessionalAmateur
  • 3,967
  • 9
  • 41
  • 62

3 Answers3

2

Default Initial size:

Larger of 1/64th of the System's physical memory on the machine or some reasonable minimum. Before J2SE 5.0, the default initial heap size was a reasonable minimum, which varies by platform.

Kumar Vivek Mitra
  • 32,278
  • 6
  • 43
  • 74
  • But if I specify the max, how does the system ensure it gets contiguous memory? – ProfessionalAmateur Aug 15 '12 at 15:11
  • @ProfessionalAmateur It doesn't have to. That's what virtual memory is for, among other things. – user207421 Aug 15 '12 at 23:10
  • @EJP - But my kernel does required it for some odd reason. `But some times XML Publisher kernel will not start if JVM could not get contiguous block of memory.` Maybe my kernel requests it from the JVM and the JVM itself doesnt care. – ProfessionalAmateur Aug 15 '12 at 23:15
  • @ProfessionalAmateur What kernel are you referring to? Some application? Kernels don't request things from the JVM: it's the other way around. I think you've misunderstood something here. The last non-virtual-memory system I worked on was in 1993. – user207421 Aug 21 '12 at 05:28
  • @EJP - This is a BI Publisher kernel for an Oracle product we have on a large enterprise system. Essentially a mail merge process that takes XML values and merges them with a report template to produce reports/pdfs/excel/etc... Im guessing that this process needs contiguous memory to interact with the JVM and not the JVM itself at this point. – ProfessionalAmateur Aug 21 '12 at 14:23
2

To answer your first question. Please look at Ted Hopp's comment. How is the default java heap size determined?

Secondly you don't need to specify and minimum and a maximum heap size. You are also inputting them incorrectly.

It should be -Xms256m -Xmx512m

Initial heap size will be 4Mbyte with a max heap of 64Mbyte on client class machines.

Community
  • 1
  • 1
Jay
  • 93
  • 6
  • But if I specify the max, how does the system ensure it gets contiguous memory if I allow the system to default with the min? – ProfessionalAmateur Aug 15 '12 at 15:12
  • 1
    Is there a reason you need a contiguous memory region? – Jay Aug 15 '12 at 15:13
  • The JVM requires it. We are still using Oracle/Sun JDK (1.5 I believe) so it requires contiguous memory. Our documentation states `But some times XML Publisher kernel will not start if JVM could not get contiguous block of memory.` – ProfessionalAmateur Aug 15 '12 at 15:18
  • I see. Well have you tried without setting the initial heap size? It should (or at least I would hope it should) do some talking with the OS to request the address space as the requirement grows. If you are on a machine with limited memory, the only option would be to go 64bit java as getting contiguous memory region is easier in that address space. – Jay Aug 15 '12 at 15:34
  • I can try that, Im searching for info on how the JVM does that though before I do. JRockit JVM doesnt require contiguous memory too, but I do not want to swap the JVMs on all my servers if I can help it now. Appreciate the input – ProfessionalAmateur Aug 15 '12 at 15:41
0

Don't put the =:

-Xms256m -Xmx512m

I think that the default has historically 2 MB, but it depends on your version of Java and your platform. I'll try to dig up the docs.

davidfmatheson
  • 3,409
  • 16
  • 25