Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase the java heap size in netbeans?

I am trying to build a lexicon trie of almost 110000 words in java in netbeans. My code is running fine but it gives an Exception as follows:

   Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOfRange(Arrays.java:3209) at java.lang.String.<init>(String.java:215) at java.nio.HeapCharBuffer.toString(HeapCharBuffer.java:542) at java.nio.CharBuffer.toString(CharBuffer.java:1157) at java.util.regex.Matcher.toMatchResult(Matcher.java:232) at java.util.Scanner.match(Scanner.java:1270) at java.util.Scanner.nextLine(Scanner.java:1517) at lexiconbuild.model.Lexicon.<init>(Lexicon.java:29) at lexiconbuild.model.LexiconBuild.main(LexiconBuild.java:17) Java Result: 1 

I was wondering if someone could help me with increasing the java heap space in netbeans.

like image 901
Noopur Phalak Avatar asked Mar 17 '13 12:03

Noopur Phalak


People also ask

Can we increase Java heap size?

To increase the Application Server JVM heap sizeNavigate to the JVM options. Edit the -Xmx256m option. This option sets the JVM heap size. Set the -Xmx256m option to a higher value, such as Xmx1024m.

How do I increase allocated heap size?

1)Change the gradle. properties file and change the heap size as per your requirement. 2)"Edit Custom VM Options" from the Help menu.

How much memory does NetBeans?

A medium-sized project currently open in NetBeans is consuming about 184 MB of memory on this machine, with peaks noticeably higher while compiling. As with any advanced design tool, NetBeans will always cheerfully accept more hardware resources and perform better for having them.


1 Answers

You can set it in NetBeans in the project properties -> Run -> VM options

  1. Right click on your project "Properties"
  2. Select "Run" category.
  3. Enter your arguments(-Xmx512m) in the "VM Options" text box.

Example: Putting -Xmx512m in the "VM Options" text box gives 512Mb maximum heap size to your Java program.

like image 178
1218985 Avatar answered Sep 21 '22 12:09

1218985