Page 1 of 1

Arduino IDE Java Errors

Posted: Fri Apr 04, 2014 4:46 pm
by avrdude
Hi ,
I know I brought this up a while ago, but I never found a solution, so here I am again.
I am running the Arduino IDE on my Windows laptop, and after opening a few sketches (doesn't matter if the windows are still open, they could be closed), it starts to lag severely and a whole heap of Java errors come up at the bottom:
"Exception in thread "AWI-EventQueue-0" java.lang.OutOfMemoryError: Java heap space"
And then a whole heap more errors about other stuff.
Since my last post on this, I reinstalled Java and Arduino, with no better results.
I have also researched this and it appears there is only a few people with this issue - and they all use Arduino on Linux.
Because on Linux, there is a simple solution. Java is running out of memory (impossible on my pc though, it has 16GB), so LINUX users simply run Arduino with -xmx2048m where 2048m is the memory you want the program to have.
But of course on Windows you cannot do this.
And more interesting still is why I have this issue and almost no one else has. My pc has 16GB of RAM, which is more than enough, and there is no RAM corruption (I have tested).
I monitored the RAM usage of the Arduino IDE, it gets to about 165MB then crashes.
I am even more surprised because this is a very small amount to allocate to a program. I have had one program using 4GB before, with no issues despite some lag.

Anyone have any suggestions?

Thanks

Re: Arduino IDE Java Errors

Posted: Fri Apr 04, 2014 11:01 pm
by cef
It's a limitation in Java that it's that small. Doesn't have anything to do with Windows specifically.

You can change it in Windows via the Java control panel. Look at something like this for how: http://www.auditmypc.com/java-memory-xmx512.asp

BTW: The max Java can allocate for 32 bit Windows is about 1280MB (from memory). If you need more RAM than that for Java, use a 64 bit JVM.

Re: Arduino IDE Java Errors

Posted: Mon Apr 07, 2014 12:31 pm
by avrdude
Ah yes thank you cef! That seems to have done the trick.
I still wonder why it happened to me but not many others...
Thanks for the help

Re: Arduino IDE Java Errors

Posted: Tue Apr 08, 2014 12:12 am
by cef
Well the way the Arduino IDE is written, I think it uses more memory the more extras you add to it.

So the more boards in boards.txt, the more libraries, etc, the more memory it uses.

Re: Arduino IDE Java Errors

Posted: Sun Apr 13, 2014 9:01 pm
by avrdude
Actually, on further testing, it appears this did not work! So I then searched a bit more and found that I could try -xms1024m but no that didn't work either!
This is probably something to do with Java just having a complete breakdown a while ago (due to the brilliance of the wonderful Windows 8), removing itself and then saying I had already installed it. However I got it back somehow but this problem still continued. And the actual origin of the problem is unknown: suddenly one day last year I opened the Arduino IDE and there we go Java errors!
Yes I am aware that including many libraries, etc will take up memory, but it doesn't matter what sketches I open (I could open a whole heap of the "Bare Minimum" sketch), after about 10 it crashes.
All I have to say now to Java is: why?

Re: Arduino IDE Java Errors

Posted: Mon Apr 14, 2014 1:50 am
by angusgr
avrdude, how many additional libraries do you have installed and how many sketches in your sketchbook?

You might find it's something in particular that's causing it to break, rather than just the quantity. Perhaps try taking them out a few at a time and see what it takes for the errors to go away? You might be able to narrow it down.

Good luck.

- Angus