“insufficient memory for the Java Runtime Environment ” message in eclipse

后端 未结 10 1618
天命终不由人
天命终不由人 2020-12-08 03:51

When I run my Java code in Eclipse, I get the following message:

There is insufficient memory for the Java Runtime Environment to continue.
Native memory all         


        
相关标签:
10条回答
  • 2020-12-08 04:29

    You need to diagnosis the jvm usages like how many process is running and what about heap allocation. there exists a lot of ways to do that for example

    • you can use java jcmd to check number of object, size of memory (for linux you can use for example "/usr/jdk1.8.0_25/bin/jcmd 19628 GC.class_histogram > /tmp/19628_ClassHistogram_1.txt", here 19628 is the running application process id). You can easily check if any strong reference exists in your code or else.
    0 讨论(0)
  • 2020-12-08 04:33

    In your Eclipse installation directory you should be able to find the file eclipse.ini. Open it and find the -vmargs section. Adjust the value of:

    -Xmx1024m
    

    In this example it is set to 1GB.

    0 讨论(0)
  • 2020-12-08 04:34

    The message above means that you're running so many programs on your PC that there is no memory left to run one more. This isn't a Java problem and no Java option is going to change this.

    Use the Task Manager of Windows to see how much of your 4GB RAM is actually free. My guess is that somewhere, you have a program that eats all the memory. Find it and kill it.

    EDIT You need to understand that there are two types of "out of memory" errors.

    The first one is the OutOfMemoryException which you get when Java code is running and the Java heap is not large enough. This means Java code asks the Java runtime for memory. You can fix those with -Xmx...

    The other error is when the Java runtime runs out of memory. This isn't related to the Java heap at all. This is an error when Java asks the OS for more memory and the OS says: "Sorry, I don't have any."

    To fix the latter, close applications or reboot (to clean up memory fragmentation).

    0 讨论(0)
  • 2020-12-08 04:35

    If you are using Virtual Machine (VM), allocate more RAM to your VM and your problem will be solved.

    0 讨论(0)
  • 2020-12-08 04:43

    If you are on ec2 and wanted to do mvn build then use -T option which tells maven to use number of threads while doing build

    eg:mvn -T 10 clean package

    0 讨论(0)
  • 2020-12-08 04:43

    I know the question talking about eclipse but i got the similar issue many times with Intellij as well and the solution for it was easy .. Just run the 64 bit exe not the 32 one which is always the default one.

    0 讨论(0)
提交回复
热议问题