Home Java javaTutorial Example analysis of memory problems in configuring eclipse.ini in java

Example analysis of memory problems in configuring eclipse.ini in java

Apr 26, 2017 am 10:09 AM
eclipse

This article is a detailed analysis and introduction to the problem of eclipse.ini memory settings. Friends in need can refer to it

-vmargs -Xms128M -Xmx512M -XX:PermSize=64M -XX:MaxPermSize=128M
There are several questions here:
1. What are the meanings of each parameter?
2. Why can Eclipse start on some machines after I set both -Xmx and -XX:MaxPermSize to 512M, but cannot on some machines?
3. Why does Eclipse not perform the corresponding settings when writing the above parameters to the eclipse.ini file?
Let’s answer them one by one
1. What is the meaning of each parameter?
-vmargs in the parameters means setting JVM parameters, so the following are actually JVM parameters. We first understand the mechanism of JVM memory management, and then explain the meaning of each parameter.
Heap and non-heap memory
According to the official statement: "The Java virtual machine has a heap. The heap is the runtime data area, and the memory of all class instances and arrays is allocated from here. . The heap is created when the Java virtual machine starts. "The memory outside the heap in the JVM is called non-heap memory." It can be seen that the JVM mainly manages two types of memory: heap and non-heap. Simply put, the heap is the memory accessible to Java code and is reserved for developers; the non-heap is the memory reserved for the JVM for its own use, so the memory required for method area and JVM internal processing or optimization (such as JIT compiled code cache), every class structure (such as the runtime constant pool, field and method data), and the code for methods and constructors are all in off-heap memory.
Heap memory allocation
The initial memory allocated by the JVM is specified by -Xms, and the default is 1/64 of the physical memory; the maximum memory allocated by the JVM is specified by -Xmx, and the default is 1/4 of the physical memory. By default, when the free heap memory is less than 40%, the JVM will increase the heap until the maximum limit of -Xmx; when the free heap memory is greater than 70%, the JVM will reduce the heap until the minimum limit of -Xms. Therefore, the server generally sets -Xms and -Xmx to be equal to avoid adjusting the heap size after each GC.
Non-heap memory allocation
JVM uses -XX:PermSize to set the initial value of non-heap memory, the default is 1/64 of physical memory; XX:MaxPermSize sets the maximum size of non-heap memory, the default is 1/64 of physical memory /4.
JVM memory limit (maximum value)
First of all, JVM memory is limited to the actual maximum physical memory (nonsense! Haha). Assuming that the physical memory is infinite, the maximum value of JVM memory has a lot to do with the operating system. To put it simply, although the controllable memory space of a 32-bit processor is 4GB, the specific operating system will set a limit. This limit is generally 2GB-3GB (generally speaking, it is 1.5G-2G under Windows systems and 1.5G-2G under Linux systems). 2G-3G), and there will be no restrictions on processors above 64bit.
2. Why can Eclipse start on some machines after I set both -Xmx and -XX:MaxPermSize to 512M, but cannot on some machines?
Through the above introduction to JVM memory management, we have learned that JVM memory includes two types: heap memory and non-heap memory. In addition, the maximum memory of JVM first depends on the actual physical memory and operating system. Therefore, setting VM parameters causes the program to fail to start mainly for the following reasons:
1) The value of -Xms in the parameter is greater than -Xmx, or the value of -XX:PermSize is greater than -XX :MaxPermSize;
2) The sum of the value of -Xmx and -XX:MaxPermSize exceeds the maximum limit of JVM memory, such as the maximum memory limit of the current operating system, or actual physical memory, etc. Speaking of actual physical memory, one thing to note here is that if your memory is 1024MB, it may not be 1024MB used in the actual system, because part of it is occupied by the hardware.
3. Why does Eclipse not perform the corresponding settings when writing the above parameters to the eclipse.ini file?
Then why are the same parameters valid in shortcuts or command lines but invalid in the eclipse.ini file? This is because we did not follow the setting rules of the eclipse.ini file:
The parameters are in the form of "item value". If there are spaces in the middle, they need to be written in a new line. If there are spaces in the value, they need to be enclosed in double quotes. For example, we use the -vm C:\Java\jre1.6.0\bin\javaw.exe parameter to set up the virtual machine. In the eclipse.ini file, it should be written like this:
-vm
C:\Java\ jre1.6.0\bin\javaw.exe
As mentioned above, the final parameters can be written like this in eclipse.ini:
-vmargs
-Xms128M
-Xmx512M
-XX:PermSize=64M
-XX:MaxPermSize=128M
The actual running results can be viewed through the "Configuration Details" button in the "Help"-"About Eclipse SDK" window in Eclipse.
In addition, it should be noted that the content of the eclipse.ini file that comes with the Eclipse compressed package is as follows:
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Xms40m
-Xmx256m
The meaning of –launcher.XXMaxPermSize (note that there are two connecting lines at the front) and -XX:MaxPermSize parameters are basically the same, I think the only one The difference is that the former is the parameter set when eclipse.exe is started, while the latter is the parameter in the JVM used by eclipse. In fact, just set one of the two, so here you can comment out –launcher.XXMaxPermSize and the next line with #.
3. Other startup parameters. If you have a dual-core CPU, maybe try this parameter:
-XX:+UseParallelGC
to make the GC execute faster. (Just a newly added parameter for GC in JDK 5)

The above is the detailed content of Example analysis of memory problems in configuring eclipse.ini in java. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

Java Program to Find the Volume of Capsule Java Program to Find the Volume of Capsule Feb 07, 2025 am 11:37 AM

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

PHP vs. Python: Core Features and Functionality PHP vs. Python: Core Features and Functionality Apr 13, 2025 am 12:16 AM

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

Create the Future: Java Programming for Absolute Beginners Create the Future: Java Programming for Absolute Beginners Oct 13, 2024 pm 01:32 PM

Java is a popular programming language that can be learned by both beginners and experienced developers. This tutorial starts with basic concepts and progresses through advanced topics. After installing the Java Development Kit, you can practice programming by creating a simple "Hello, World!" program. After you understand the code, use the command prompt to compile and run the program, and "Hello, World!" will be output on the console. Learning Java starts your programming journey, and as your mastery deepens, you can create more complex applications.

PHP: The Foundation of Many Websites PHP: The Foundation of Many Websites Apr 13, 2025 am 12:07 AM

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

See all articles