This article is a mirror article of machine translation, please click here to jump to the original article.

View: 67240|Reply: 2

[Source] JAVA Error occurred during initialization of VM error

[Copy link]
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 used
Next:The difference between SSL, OV, DV, and EV certificates
 Landlord| Posted on 8/14/2017 4:51:30 PM |
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)



java version "1.8.0_144" 64-bit server-side mode, 80g memory, no problem

 Landlord| Posted on 9/1/2020 10:29:04 PM |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com