NetBeans Low on Memory Error - java

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!

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.

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!

Allocate more memory for NetBeans.
Go to your NetBeans home directory.
Open the netbeans.conf file in the etc directory. //under:Resource/NetBeans/etc
Find the netbeans_default_options parameter in the file.
Set the -J-Xms and -J-XX to larger values. ex:-J-Xms256, -J-XX256
Hope for help.

Related

JAVA does not work with the same resources on Netbeans Project and JAR file when the compile the code

When I build the Project and run the program on netbeans, it runs perfect and fast enough, yet when I export the jar file and start the program on that it is slow and stuck at the middle of the process.
I track the java resource usage and I found the memory problem.
How can I overcome this problem? I want to use the program same as on the Netbeans. How can I remove the constraint to resource usage of JAVA?
I am sorry, I forgot to tell I tried that. I think heap size is different than what I need. -Xmx and -Xms does not work. They don't change the java.exe or javaw.exe memory usage. I need what the Netbeans do to use more ram.
All pictures shows that the problem clearly.
Netbeans runs the program on java with more ram:
When the process parse and write to excel started it use so much ram:
However, when I start the program on JAR file, process so slow and use limited ram:
At the end of the process (parse and write to excel) it was very slow and after a while it stuck because of the lack of memory space that java allows:
If you are sure that memory limit is the only problem then set the maximum heap size that JVM can use, add -Xmx2G command line parameter to java.exe.
You can read more on -X options here.
Problem solved, but I don't know why JDK 1.8 block the memory usage?
Answer : http://forums.netbeans.org/viewtopic.php?p=167390

flexmojo java heap space error

When I lunch maven flexMojo compile plugin from eclipse in windows OS I get java heap space error .
any idea on increasing memory for maven ?
I tired this in windows envirement variables :
MVN_OPTS = -Xmx1024m -XX:MaxPermSize=512m
and it didn't help .
Shouldn't this be MAVEN_OPTS instead of MVN_OPTS?
Some one post the answer in the web . a copy paste from the original post :
The solution obviously is to increase the maximum heap size which is represented by the JVM -Xmx argument. Now there are a number of places you can find this argument (STS.ini is one of them) , but here's the one place I found that really makes the difference.
Goto the 'Run Configurations' popup of the current maven run you are trying to use (can be accesed by right clicking your project and selecting 'Run As')
Select your current run under 'Maven Build' in the tree
Select the the JVM tab and add your requested -Xmx settings (I chose -Xmx512m)
Press 'Apply' and 'Run'

How do I run stand-alone Eclipse MAT?

I generated hprof using jmap.
sudo ~/jdk/bin/jmap -F -dump:file=app.hprof 5003
Now, I am getting OOM / 'Java Heap Space' error while parsing *.hprof in eclipse. I think I need to run it as stand-alone.
How do I run it? any references?
I assume, you've downloaded Eclipse MAT in the form of Standalone Eclipse RCP Application. If not - do so now, and extract the archive to a folder that suits you.
You're getting the OOME, because MAT has too few memory available (the heap-dump you're parsing is too big).
To make the heap bigger, edit your MemoryAnalyzer.ini file (it should be in your MAT directory), and add the following lines to it:
-vmargs
-Xmx2048M
The 2048M means 2 gigabytes of heap space will be available to the JVM. Perhaps 1 gigabyte will be enough for you.
Note!
If you are using MAT as an Eclipse plugin, you can probably do the same trick by editing eclipse.ini in your Eclipse directory.

Location of Java dump heap file when using jconsole?

Well this is embarrassing ...
I'm starting to play with the Eclipse Memory Analyzer to look for Java memory leaks on a Windows box. Step 1 is to obtain a heap dump file. To do this I start my Java (javaw.exe) process from within Eclipse and connect to it with jconsole. Then on the jconsole MBeans tab I click the dumpHeap button. The first time I did this, I saw a pop-up saying it had created the heap dump file, but not giving its name or location. Now whenever I do a dumpHeap again while connected to a different javaw.exe process, jconsole says:
Problem invoking dumpHeap : java.io.IOException: File exists
and of course doesn't give its name or path. Where could it be?
I've searched my C: drive (using cygwin command line tools) for files containing "hprof" or "java_pid" or "heapdump" and didn't find anything plausible. I've even used the Windows search to look for all files in my Eclipse workspace that have changed in the last day.
I'm using the Sun Java 1.6 JVM, and don't have -XX:HeapDumpPath set.
Update (28 April 2010): My original heap file location must have been determined by jconsole, the tool I triggered the heap dump from. The JVM's heap dump location must apply only to heap dumps it triggers (eg, on an OutOfMemoryException).
Matt B's suggestion to use jvisualvm nicely solves my problem by pointing me to a far more useful replacement for the old jconsole. It has a nice memory profiler that shows which types of objects are most numerous and hold the most memory. And it has a monitor that shows actual memory use over time. When you ask it for a heap dump, it tells you the file name even! The Eclipse Memory Analyzer gives you full details.
Try jvisualvm, it has a much better interface.
Note that starting with JDK version 6 update 7 or greater, Java VisualVM is bundled with JDK. See here.
According to the docs for the Sun Java SE6 JVM:
By default the heap dump is created in
a file called java_pid<pid>.hprof in the
working directory of the VM
In Eclipse, the working directory is defined on the "Arguments" tab of the "Run Configurations" dialog. The default value is the same directory as the class that you are running.
why don't you set the first parameter for dumpHeap(String,boolean) when you try to invoke dumpHeap() from jconsole? it's the generated heapdump file's location and filename.
You could always use ProcessMonitor to see where it's trying to write to :) Done this myself in the past.
I found the dumped file into the same folder where the .bat file whic launch my java application is placed. (I'm using windows 8.1, java 7)
In my case jboss, /jboss-as/bin/ folder.
To find it I searched * files, with today creation date and more than 200MB.

OutOfMemory in Eclipse in a Launched process

I have an OutOfMemory (heap size) in eclipse using a third party plugin
The plug in is Adobe Livecycle work bench and during the out of memory the
plugin is retrieving via WS (using Axis) a list of around 70 workflow components
on my server
Here is a extract of my call stack in Eclipse
... at org.eclipse.equinox.launcher.Main.main(Main.java:1144)
Caused by: java.lang.OutOfMemoryError: Java heap space; nested
exception is: java.lang.OutOfMemoryError: Java heap space at
org.apache.axis.message.SOAPFaultBuilder.createFault ...
I am using this eclipse.ini
-showlocation
-vm
C:\bea920\jdk150_04\bin\javaw.exe
-vmargs
-Xms512M
-Xmx1024M
I don't use any commandline options
I have added -Xmx1024m to my only Installed JRE in Java/Installed JREs
It seems to me that :
-eclipse is not OutOfMemory itself
it displays only 300Mo out of 1024Mo used
it continues working properly
-the plugin launch its axis parsing without giving it enough memory
Questions :
- Are my suppositions right ?
- How do I find where and how to give more memory to the process launched by eclipse launcher ?
Have you changed your launched VM arguments from the preferences window? Try this:
Window->Preferences
Java->Installed JREs
(select your jre here)->Edit..
Default VM Arguments: -Xmx1024m (or whatever size you like)
Edit 1: Based on your comments, I see that you've already tried this. I assumed that you did not try it based on the portion of your question that reads "How do I find where and how to give more memory to the process launched by eclipse launcher ?". I guess we all know what happens when we assume!
Have you considered upping the memory to something larger just to see if you can get it to run (and possibly get some more info about what is causing it to crash)? Try -Xmx2048m or larger depending on your available memory.
Can you add some information to your question that gives us an idea of what the plugin does? Is this project a web service? etc..
See if you are passing Xms and Xmx options in the command line that you are running eclipse with. The values there will override the values in the eclipse.ini
I think you need to edit your eclipse.ini file which is located in the
same directory as your eclipse exe file. It will contain the -Xms settings
which you can then change.
I recommend running eclipse with the -clean option to purge any caches and re-read your settings.
Also, I've had success moving the eclipse.ini out of the eclipse directory (so there's no eclipse.ini), running eclipse, exiting, moving the ini file back and running again. I didn't bother to try to understand why that helped.
Add -XX:MaxPermSize=256m
This is yet-another-memory-type in Java.
I was able to find were the problem is
I used Fiddler with eclipse (using proxy settings)
This way I was able to spot that the soap answer was an OutOfMemory
soapenv:Fault
faultcode soapenv:Server.generalException
faultstring java.lang.OutOfMemoryError: Java heap space; nested exception is:
java.lang.OutOfMemoryError: Java heap space
So the problem was on the server
I have now another problem : the server builds an answer which is to big for eclipse
Thank you for your answers

Categories

Resources