jvm issue at startup

I can set the max memory as 1000 and not more than that, if I set the memory more than that, it throws the following error.

Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.

My question is, why jvm looks for the max memory at startup?

Thanks in advance.


The Sun JVM needs a contiguous area of memory for its heap. Using the tool vmmap from the Sysinternals suite you can examine the memory layout of the Java process exactly. To do that, write a simple Java program like this:

public class MemoryLayout {
    public static void main(String[] args) throws java.io.IOException {
        System.in.read();
    }
}

Compile that program and run it using the large heap settings

javac MemoryLayout.java
java -Xmx1000m -Xms1000m MemoryLayout

Then, start vmmap , select the java process and look for the yellow memory region whose size is larger than 1000000k. This is the JVM heap. Look further below, and you will eventually find a purple row indicating that there is a DLL file mapped. This DLL file prevents your JVM heap from growing bigger.

If you know what you are doing, you can then rebase that DLL, so it will be loaded at a different address. Microsoft provides a tool called rebase.exe as part of the Microsoft Platform SDK (I have version 5.2.3790.1830).


There are two command line parameters that directly control the size of the (normal) heap:

  • -Xmx<nnn> sets the maximum heap size
  • -Xms<nnn> sets the initial heap size
  • In both cases <nnn> is a number of bytes, with a k or m on the end to indicate kilobytes and megabytes respectively. The initial size gives the heap size allocated when the JVM starts, and the maximum size puts a limit on how big it can grow. (But the JVM also allocates memory for buffers, the "permgen" heap, stacks and other things ... in addition to the normal heap.)

    It is not clear what options you are actually giving. (A value of 1000 doesn't make any sense. The -Xmx size has to be more than 2 megabytes and the -Xms size has to be more than 1 megabytes; see this page.)

    There are advantages and disadvantages in making the initial heap size smaller than the maximum heap size; eg -Xms100m -Xmx1000m . But there is no point making the maximum heap size larger than the amount of virtual memory your machine can allocate to the JVM.


    why jvm looks for the max memory at startup.

    It wants to make sure that it can eventually allocate the maximum amount which you said it could have.

    Why do you need to set a higher maximum then your machine actually supports?

    Answer: It would make JVM configuration easier, if you could just set it to basically unlimited, especially if you deployed to different machines. This was possible in earlier versions, but for the current Sun JVM, you have to figure out a "proper" value for every machine. Hopefully, there will be more clever/automatic memory settings in the future.

    链接地址: http://www.djcxy.com/p/82976.html

    上一篇: 在命令提示符下安装时出现exoPlatform错误

    下一篇: 启动时出现jvm问题