5

I know this is a common question/problem. I'm wondering where to get started with it.

Running java on windows server 2008, we have 65GB memory, and it shows 25GB free. (Currently a couple of guys are running processes).

systeminfo | grep -i memory

shows:

Total Physical Memory: 65, 536 MB
Available Physical Memory: 26,512MB
Virtual Memory: Max Size 69,630 MB
Virtual Memory: Available 299 MB
Virtual Memory: In Use: 69, 331 MB. 

Really just wondering how I go about solving this problem.

  • Where do I start?
  • What does it mean that more virtual memory is being used than physical memory, and is this why java won't start?
  • Does java want to use virtual memory rather than physical memory?

java -version

gives me:

Error occured during initialization of VM could not reserve enough space for object heap

More specific questions:

  • Why doesn't the JVM want to use the free phsyical memory?
  • How much memory does a java command (like java -version) want to use if you don't specify Xms parameters?
  • Would simply assigning more virtual memory be a good solution to the problem?
dwjohnston
  • 11,163
  • 32
  • 99
  • 194
  • Are you using a 64-bit VM or a 32-bit VM? – Louis Wasserman Feb 17 '13 at 22:55
  • `java -version` for the bits. Also, what is your initial heap currently set to? – Ryan Stewart Feb 17 '13 at 23:11
  • I can't do `java -version` it gives me the space error. (What's actually happening when I call `java -version`? Is it creating a JVM and then finding out what version it is from that JVM?). Not sure what you mean by initial heap, and how would I find out? – dwjohnston Feb 17 '13 at 23:16
  • Possible duplicate: http://stackoverflow.com/questions/9303889/error-occurred-during-initialization-of-vm-could-not-reserve-enough-space-for – Christian Garbin Feb 17 '13 at 23:20
  • using `java -Xms64m -Xmx64m -version` I get `java version "1.7.0_07" SE Runtime envrionment Java HotSpot 64-bit server VM (build 23.3-b01, mixed mode)` – dwjohnston Feb 17 '13 at 23:23
  • The `-Xms64m` in the above is your initial heap setting. You'll get the error you described if this exceeds available memory. I'm not sure of the details, but I believe the memory must be contiguous, too. – Ryan Stewart Feb 17 '13 at 23:27
  • So the question I have, is why doesn't java want to use the physical memory that's available? For example at the moment it's showing 29gB available physical memory, and 8gB available virtual memory. `java -Xms4g -Xmx4g -version` will work, but `java -Xms16g -Xmx16g -version` will give me the space error. Why won't it use that physical memory? – dwjohnston Feb 17 '13 at 23:34
  • So I wrote this question right at the start of my career - like first month on the job. Seven years later and I have this kind of thing is no way near what I do and I find it amazing that a graduate developer was getting into this and doing ok. – dwjohnston Jul 26 '20 at 07:06

3 Answers3

2

I got the same issue. From the analysis, we found that the machine have low swap space. Please increase the swap space and verify.

user2428118
  • 7,935
  • 4
  • 45
  • 72
0

As I discovered when I had a similar problem (though with a lot less memory on the system -- see Cannot run a 64-bit JVM in 64-bit Windows 7 with a large heap size), on Windows the JVM will try to allocate a contiguous block of memory.

So my bet is that while you have enough total memory, you don't have enough contiguous memory.

Community
  • 1
  • 1
QuantumMechanic
  • 13,795
  • 4
  • 45
  • 66
  • What does it matter if the memory isn't contiguous? Would it be possible to tell java not to look for contiguous memory? – dwjohnston Feb 18 '13 at 00:02
  • 2
    It matters because that's what the JVM wants. It attempts to allocate the memory all-or-none. See http://stackoverflow.com/a/497961/411393 for example as to why the JVM wants contiguous memory (which also implies there's no way to tell it not to require it). – QuantumMechanic Feb 18 '13 at 03:35
  • 1
    Okay, so what do I do to ensure memory is contiguous? I've got plenty of it in the system. Also, I thought with virtual memory computers a program is presented with a virtual contiguous block of memory and the program doesn't get to know (or care) whether the real memory is contiguous or not. – Ryan Sep 03 '13 at 16:21
0

At least to see java version run java -Xmx64m -version this should show you the version if needed. Then you can try increasing Xmx and see at what value it fails

NithinS
  • 61
  • 1
  • 2