NetBeans Low on Memory Error

17,076

Solution 1

The simplest answer for my problem was a trick to identify. I had a number of netbeans projects into my working directory. Suppose that my directory D:\NetBeans\WorkSpace contains about 300 projects! What I done is that simplify the directory moved the old projects into a new directory and only a few projects left into my netbeans working space. The error message goes off after moving a number of projects into a new directory. The thing is when netbeans starts up it loads the projects into the memory and if you have a lot of projects into the loading directory it will cause to leak the memory!

Solution 2

With -Xms3G, it means that your JVM will be started with Xms amount of memory, the initial memory allocation.

But instead use -Xmx3G which will be able to use a maximum of Xmx amount of memory, the maximum memory allocation.

1.Netbeans Heap Size

If you want to increase the NetbeansIDE heap size, then edit the following file.(the etc folder from your Netbeans installation dir)

C:\Program Files\NetBeans\etc\netbeans.conf

Find the following line and add -J-Xmx3G, you can specify any size. I have provided 3G for eg.

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Xmx3G -J-XX:PermSize=32m ......."

2. Project settings for running a project by increasing Heap size from Netbeans

Right Click Project -> Properties -> Run -> VM Options -> Customize Button. You will find many options for VM, specify value for Xmx.

3. Run a jar file by providing VM options to increase heap size, outside of Netbeans.

Run form command line or write a script.

java -Xmx3G -jar filename.jar

Hope this may help.

Share:
17,076

Related videos on Youtube

Java Nerd
Author by

Java Nerd

Updated on September 14, 2022

Comments

  • Java Nerd
    Java Nerd over 1 year

    I am new to this kind of error in Netbeans. I have been working in Java J2SE using my net beans 8.0.2. I am doing Fuzzy Search on Strings usually strings having 300-500 length. I am using Levenshtein and Jaro Winkler Algorithms to find the Distance between the strings. There are about 1500 iterations to find the distance between the strings! The problem is that my net beans often gives error for:

    Low on Memory, Error Unable to Compile
    

    I have done some search online to get rid of this error and found how to increase the heap size by adding

    -Xms3G
    

    command means to give 3GB space for the heap! but the error still comes up in the compilation process and project run in net beans.

    Can somebody help me out how to get rid of this error because when it happen i got this error

     java.lang.noClassDefError
    

    Please help me getting rid of this error I am a newbie for this error!

  • Java Nerd
    Java Nerd over 9 years
    so it means that if i make it as .jar file, will it work for .jar as well or just for the netbeans?
  • Nikolaii99
    Nikolaii99 over 8 years
    Looks like there's a mistake in your netbeans_default_options example because you say that you've provided 3G for example, but 3G or its M equivalent does not exist in your example ?
  • pmverma
    pmverma over 8 years
    Thanks, I have modified it.