Home  >  Q&A  >  body text

java - 今天开始用eclipse编写servlet程序,但是经常写着写着就变的很卡,最后强行关闭,又重启还是不行,为什么呢?

有时候会自己卡在那,有时候eclipse提示出现问题,要求我查看workspace.metadata.log文件,log文件提示的错误是:
!ENTRY org.eclipse.osgi 4 0 2016-11-05 15:17:10.371
!MESSAGE Error stopping the framework.
!STACK 0
java.lang.OutOfMemoryError: PermGen space


我在百度上查的java.lang.OutOfMemoryError解决方案是在tomcat配置里扩大内存,如图,红色部分是根据提示添加的:

还有的说在eclipse里修改Window/Perferences/General里的Startup and Shutdown,把打勾的都去掉。

我试了两种方法都不行,再次打开eclipse编程过一会还是会边卡,求大神指教,这是为什么啊?

迷茫迷茫2764 days ago969

reply all(4)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 10:21:04

    1 As shown below, you can find ecplise.ini under the installation path of ecplise, select a text editor to open it, check the parameters of these settings in the box, and set them according to your own memory conditions


    Secondly, you can also take a picture of the virtual memory of the jdk you are using in ecplise
    Find the window->preferences->Java->Installed JRE in eclispe, click the Edit button on the right, in the editing interface In the "Default VM Arguments" option, fill in the following values.
    -Xms64m -Xmx128m

    3. Modify Run Configurations

    Right-click on the code, click "Run As" -> "Run Configurations", and fill in the following values ​​in "VM arguments:" in the Arguments parameter.
    -Xms64m-Xmx128m

    Finally, these parameter values ​​are not for you to just fill in. It is best to set reasonable values ​​based on the memory of your own machine

    The following is the official description
    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 comes from here. Allocation. The heap is created when the Java virtual machine starts. "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 the physical memory; XX:MaxPermSize sets the maximum size of the non-heap memory, the default is 1/4 of the physical memory.
    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.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 10:21:04

    • Increase memory/replace SSD

    • Change computer

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:21:04

    You can try adding these configurations to the JDK configuration of tomcat. If the screenshot cannot be uploaded, it is in the Optional Java VM arguments in server>tomcat>JDK

    reply
    0
  • 阿神

    阿神2017-04-18 10:21:04

    Make it simple, switch to idea (but the configuration is better)

    reply
    0
  • Cancelreply