|
|
Posted on 8/14/2017 4:49:22 PM
|
|
|
|

Error occurred during initialization of VM Could not reserve enough space for 3145728KB object heap
Recently working on a program for Java. Originally, I have always liked Java's memory management, no need to worry about allocating memory, just allocate, the garbage collector will reclaim the memory for you. Now the program is developed with a large amount of data, and for the sake of speed, I am going to load all the information into memory, which will ensure a fast response. I'm still repeatedly counting the memory, thinking about my own data amount, which should be enough at the beginning (my machine has 4G memory, although Windows recognizes 3.5G, but it should be fine compared to my current data volume).
Unexpectedly, the program of the first experiment ran for a few hours and encountered an Out of Memory Exception. Looking at my own VM settings, I set -Xms512M -Xmx1024M. Without thinking about it, I directly changed it to -Xms512M -Xmx2048M, and the result was that I could not reserve enough space for object heap. The program can't get up. Only then did I realize that there was still a limit to the original maximum memory. I searched the Internet and found many articles discussing this issue. Finally, I found the most useful article on BEA's DEV2DEV forum
Here moderator YuLimin did the test and came to the conclusion:
Company JVM version Maximum memory (mega) client Maximum memory (mega) server
SUN 1.5.x 1492 1520
SUN 1.5.5(Linux) 2634 2660
SUN 1.4.2 1564 1564
SUN 1.4.2(Linux) 1900 1260
IBM 1.4.2(Linux) 2047 N/A
BEA JRockit 1.5 (U3) 1909 1902
I'm using JDK1.6.0_05 now, tested it. The biggest thing in the client state is that my JDK does not recognize the -Server parameter and cannot test the server state. Estimates are about the same.
SUN 1.6.0 1442 N/a
It seems that it is impossible to use large memory in Java. And the general saying is that if the memory is too large, the garbage collection time will be long. This is also understandable, generally collected when the memory is not enough, scanning 2G memory is of course much slower than 1G, and there are more memory objects, the estimated relationship is exponentially increasing.
Attached below are YuLimin's test methods and test records.
Test Method:Test with the java -XmxXXXXM -version command under the command line, and then gradually increase the value of XXXX, if it is executed normally, it means that the specified memory size is available, otherwise an error message will be printed.
Test the maximum supported memory of the JVM, and then set the environment variables on the system
Variable name: _JAVA_OPTIONS Value: - Xmx1G
|
Previous:jQuery fullscreen plugin "jQuery Fullscreen Plugin" is usedNext:The difference between SSL, OV, DV, and EV certificates
|