Arduino/Teensy IDE Crashes Constantly - Java heap errors

Suggestions for fixing Java for Windows 10 ?

Here's a first guess for Windows.

Extract this ZIP to get "arduino.l4j.ini". Then copy it to your Arduino executable folder, replacing the file already there. On Windows, I believe the default location is C:\Program Files (x86)\Arduino.

Please let me know if this works? Windows is the platform I use the least (I mainly use Linux, occasionally MacOS), so I'm really depending on feedback to know if this works...
 

Attachments

  • arduino_l4j_ini.zip
    251 bytes · Views: 24
Here's a first guess for Windows.

Extract this ZIP to get "arduino.l4j.ini". Then copy it to your Arduino executable folder, replacing the file already there. On Windows, I believe the default location is C:\Program Files (x86)\Arduino.

Please let me know if this works? Windows is the platform I use the least (I mainly use Linux, occasionally MacOS), so I'm really depending on feedback to know if this works...

Paul:

On my Windows 11 machine, the replacement arduino_l4j.ini file caused Arduino IDE 1.8.19 + TD 1.59b3 to not startup. However, if I edited the contents of that file to the that shown below, the Arduino IDE would then startup OK. This machine has 64GB RAM, so I don't think the failure is due to a lack of RAM.

Code:
-Xms256M
-Xmx1024M
-Dfile.encoding=UTF8
-Djava.net.preferIPv4Stack=true

If you have any suggestions on where to look in order to get more details on the failure, I'd be glad to help by investigating further.

Mark J Culross
KD5RXT
 
Paul:

With a little more experimentation, I have found that the "Xmx????M" config item can be changed as high as 1448 & the Arduino IDE will start & run successfully. Change it to 1449 on my particular PC & the Arduino IDE will no longer start. However, at 1448, only one copy of the Arduino will start successfully (my TeensyMIDIPolySynth (TMPS) project includes two Teensy processors, so I very often open two copies of the Arduino IDE & edit the sketches in each as I add/modify capabilities). Again, on my particular machine, changing that particular config item to 1024 allows two copies of the Arduino IDE to both start & run successfully.

Mark J Culross
KD5RXT
 
Got extended wavetables to build

Sorry, for the delay, as we had family gatherings in celebrating my wife's 81st birthday and welcoming a 2 year old dog to our home.
Paul, thanks a million for your help. (Attempt 2. Sure hope this works by pasting!)
The info regarding of events happening is in chronological order. I disabled WiFi and Airplane mode is on.
The -Xmx1024M did not work for my Windows 10 PC with 16 GB.
I used -Xmx1024M instead of -Xmx2048M, for the arduino_debug.l4j.ini file.
Result:
D:\Documents\arduino-1.8.19_T1.57>arduino_debug
Loading configuration... Initializing packages... Preparing boards... Starting...

So the WF2 sketch of 444 files (including 220 wavetables) loaded in about 70 seconds for Arduino 1.8.19.
This temporary sketch is very minimal and does not even include a synth.

Building for Teensy 4.1 : (220 wavetables)
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

The WF2 444 files did load in the Arduino 1 IDE. A word search (for ALL files) caused:
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
at java.lang.String.toLowerCase(String.java:2590)
at java.lang.String.toLowerCase(String.java:2670)
at cc.arduino.view.findreplace.FindReplace.find(FindReplace.java:317)
at cc.arduino.view.findreplace.FindReplace.find(FindReplace.java:367)
at cc.arduino.view.findreplace.FindReplace.find(FindReplace.java:367)
at cc.arduino.view.findreplace.FindReplace.find(FindReplace.java:367)
at cc.arduino.view.findreplace.FindReplace.find(FindReplace.java:367)
at cc.arduino.view.findreplace.FindReplace.find(FindReplace.java:367)
at cc.arduino.view.findreplace.FindReplace.find(FindReplace.java:367)
 
Another Arduino IDE 1 observation: (This is more noticeable when large projects are opened and closed.)
From my interpretation of what happens is that the memory that the IDE uses is not released in all circumstances.
I've watched the Win 10 Task Manager can see when CPU (Java) is loading a sketch. D: Disk is read for the source files.
I normally "Close" sketches. I just realized that Quit closes all open sketches. I believe "X" behaves even differently. (?)
(I did see a brief Arduino explanation of "Close" and "Quit" and it did not agree with what I witness.)
Memory % does increase with starting a sketch. Quit decreases Memory %.
I wanted to have documentation to prove my point by showing Ram use after opening and closing my biggest sketches.
I spent probably over an hour saving Ram use in the Task Manager and Resource Monitor (png files) but under arduino_debug
of course it does not happen.
Maybe because I did not actually modify any source code for this test. Come to think about it, I did no compiles, either. (?)
Actively editing and compiling these large sets of files in the last 2 or 3 days I have had to reboot my PC probably a couple dozen times.

Just to provide a reference, my present operational synth (to date) with 125 wavetables (281 files) build result:
FLASH: code:475064, data:4608196, headers:8548 free for files:3034656
RAM1: variables:186212, code:233048, padding:29096 free for local variables:75932
RAM2: variables:429312 free for malloc/new:94976

I made a new sketch, which simply prints the address of each wavetable in setup(). (loop() only blinks the LED.)
By commenting out a pointer (or groups of pointers) from the array and testing build results I found some suprises.
One wavetable .cpp file had an extreme size (ConcertBD). Other large wavetables were also eliminated.
I excluded some of the largest (cpp) wavetable files and their .h counterpart. The names excluded are:
ConcertBD, Dog, DoorCreaking, Door, FlKeyClick, Footsteps, GtCutNoise, GtFretNoise, GunShot,
HeartBeat, HorseGallop, Jetplane, Lasergun, Laughing, MachineGun, Punch, Scratch, Screaming,
SynMallet, SynStrings3, Telephone2, Thunder, Train, Wind, Woodblock
(I don't care for noise, anyway, and besides noise does not need to be tuned.)
BTW- Wavetable ConcertBD is so big that it (by itself) will not fit in the 8MB flash!
Other excluded wavetables would build ok, but there so big that only 4 or 5 of them can fit in 8MB of Flash at one time.

The 207 wavetable pointers to be printed in the this bareWT2 sketch now builds and loads:
FLASH: code:60624, data:7851652, headers:8360 free for files:205828
RAM1: variables:11264, code:57848, padding:7688 free for local variables:447488
RAM2: variables:12384 free for malloc/new:511904
 
So the fix works? Or is it still too early to be sure?

If yes, might be worthwhile to also follow up on the Arduino forum. As the library list keeps slowly growing, I would imagine more people still using Arduino IDE 1.8.19 on MacOS will start to encounter this problem. Who knows, might become a problem on Linux and Windows too?

I'm going to try incorporating this fix into the copy of Teensyduino using IDE 1.8.19 for MacOS. Hope you'll be willing to give the next beta a test run? For fixing this sort of problem where I can't reproduce with my normal Mac test machine, I'm really depending on your help with testing...
Some reason I didn’t get notifications on replies.

Unfortunately no the fix didn’t take. It seemed to work for a couple days but then I had to revert to the original. It’s been a little while and I can’t recall what went wrong, so what I’ll do is try the fix again and be sure to report back what the issue was this time. Life kinda got in the way as I meant to keep current here.

Of course I’m happy to help beta test Paul so no worries.

One thing I do recall is it was asking me to allow the program every time I started it, but that wasn’t the real issue.

I’ll report back here with more detailed info soon.

Thx so much Paul et al.
 
I used -Xmx1024M instead of -Xmx2048M, for the arduino_debug.l4j.ini file.
....
Building for Teensy 4.1 : (220 wavetables)
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

Are you sure -Xmx1024M was really used? Trying to reserve 2097152KB would be expected with -Xmx2048M.
 
I know I didn't respond to this in a long time; apologies. I found the fix did not work. When I try to use the fix Paul gave, the program quits shortly after launch. So I went back to the original. I'm still having the out of memory errors. I need to see if there's any input from the Arduino community.

If/when I get answers I'll post back here.

If anyone has any other suggestions, I'm all ears.

By the way, I did in fact post on an Arduino forum but got nowhere. The thread was closed.

Here it is: https://forum.arduino.cc/t/java-error-keeps-crashing-arduino-ide/1157150/12
 
Back
Top