IDE 2.10 and Stack Space

econjack

Well-known member
One of my Betas is running 2.10 and 1.58.2 on Linux and reports a 40K increase in stack usage versus 1.57. On Windows it's less dramatic, about 10K, but still significant. I do not have a Linux machine so I cannot verify, but he's a good EE guy (retired RF Engineer from Motorola) and I trust what he says. Does anyone else see these kinds of change on Windows or Linux. Anything in the libraries that might cause this?
 
Have you considered that code / data from RAM1 are allocated in 32K blocks so it may only require a small increase in either code or variables to require a full 32K page to be allocated.

After the build you should see some diagnostics:
Code:
teensy_size: Memory Usage on Teensy 4.1:
teensy_size:   FLASH: code:425260, data:296432, headers:8416   free for files:7396356
teensy_size:    RAM1: variables:119008, code:359848, padding:600   free for local variables:44832
teensy_size:    RAM2: variables:50944  free for malloc/new:473344
The memory that is "wasted" and not available for stack is indicated in the "padding:" field for RAM1. I'm guessing from your description that yours is very high and close to 32K
 
Actually on rereading your question you may be speaking about memory used by the IDE. If so, then just ignore my response
 
1.57 used gcc 5.4.1.

1.58 switched to gcc 11.3.1.

By default for Teensy 4 we're compiling with -O2 optimization which favors faster code, even if using more memory.

That may or may not be the entire reason why you're seeing a difference.
 
Last edited:
There is some padding, but not a lot, although I didn't think of that. My stats are:

Memory Usage on Teensy 4.1:
FLASH: code:230516, data:144376, headers:9100 free for files:7742472
RAM1: variables:256288, code:226968, padding:2408 free for local variables:38624
RAM2: variables:328544 free for malloc/new:195744

I have a huge struct array and if I use the PROGMEM qualifier on it, I get:

Memory Usage on Teensy 4.1:
FLASH: code:230516, data:144120, headers:8332 free for files:7743496
RAM1: variables:227616, code:226968, padding:2408 free for local variables:67296
RAM2: variables:328544 free for malloc/new:195744

so I have a large enough stack not to be too concerned.

@Paul: I need to favor speed anyway, as it's for an SDR radio and requires some fairly heavy DSP (e.g., FFTs). So far, it's working well and I've not had a stack crash. I also heard about the relatively large jump in the gcc. The parser seems a tad more strict, but nothing that causes a problem. Indeed, I'm glad we picked the Teensy 4.1,
 
Does a new install of an IDE/TeensyDuino overwrite the old gcc? What is the name of the gcc in version 1.8.19 and 2.10?
 
Does a new install of an IDE/TeensyDuino overwrite the old gcc? What is the name of the gcc in version 1.8.19 and 2.10?

The compiler (gcc) and other tools are part of the board package (TeensyDuino), as opposed to being part of Arduino (1.8.19 or 2.10), so you can use older/newer tools with either IDE. The gcc version in TeensyDuino 1.58 is 11.3.1. See forum post below.

https://forum.pjrc.com/threads/72509-Teensyduino-1-58-Released
 
Does a new install of an IDE/TeensyDuino overwrite the old gcc?

The simple answer is yes.

The complicated answer is installation works very differently depending on IDE 2.1.0 versus IDE 1.8.19.

Using IDE 2.1.0, the compiler toolchain is placed in its own directory with the version number in the pathname. Normally IDE 2.1.0 deletes everything from the old pathname and puts the new copy at its proper pathname. So even if it doesn't delete the old copy, the pathname is different depending on the version so it can't possibly use the old copy. When IDE 2.1.0 runs gcc, it will use the full pathname. If you want to see the details, in File > Preferences turn on verbose output during compile. Then Arduino will show you the commands it actually runs to compile your program and you can see the full pathname to gcc is used in every command.
 
Some more information. Our SDT has a Calibrate function that aligns the I and Q signals used in a Quadrature Sampling Detector. The code is simply reading an encoder and setting some phase parameters. The encoder response is glacial: turn the encoder one detent and it might take 30 seconds for it to respond. If we drop back to TeensyDuino 1.56, the response time is about 1 second, which is expected because of the processing be done. We have traced the bottleneck to the last two statements in the following for code block:
Code:
    for (unsigned  i = 0; i < N_BLOCKS_EX; i++) {  //N_BLOCKS_EX=16  BUFFER_SIZE=128 16x128=2048
      sp_L2 = Q_out_L_Ex.getBuffer();
      sp_R2 = Q_out_R_Ex.getBuffer();
      arm_float_to_q15 (&float_buffer_L_EX[BUFFER_SIZE * i], sp_L2, BUFFER_SIZE);
      arm_float_to_q15 (&float_buffer_R_EX[BUFFER_SIZE * i], sp_R2, BUFFER_SIZE);
      Q_out_L_Ex.playBuffer(); // play it !
      Q_out_R_Ex.playBuffer(); // play it !
    }
Dropping back to 1.57 did NOT change the encoder response. The radio does use your audio hat and its library and uses these buffers. The encoder is interrupt driven. I realize this is scant code to work with, but the entire project is about 14K lines of C source code spread over two dozen files. The project is Open Source, so I can send to to anyone who wants it.

I just had a thought: I have NOT marked the variables used in the ISR as volatile, so I'll see if that makes a difference. I'll report back if it does.
 
Well, I went back to change the attributes on the ISR variables and now I'm back to the Exit only option on the File menu. So, once again, I uninstalled IDE 2.1 and download a fresh copy and installed it from the Win zip file. When finished, same problem. I would chalk it up to a hardware issue, but 1.8.19 works fine. I really want 2.1 to work for several reasons: I really like the Hover and F12 features, and I also brag the 2.1 release up in a new revision of my book (Amazon B09WYP1ST8). I'd feel a lot better if I knew why mine fails just in case someone else has the same issue.
 
Beta Tester Compile Results on Linux

I am the beta tester mentioned earlier. I am running Pi OS (Linux) on a Raspberry Pi 4. Arduino IDE 2.1.0.

Here are the compile results using TeensyDuino 1.56.1:

teensy_size: Memory Usage on Teensy 4.1:
teensy_size: FLASH: code:224308, data:138984, headers:8412 free for files:7754760
teensy_size: RAM1: variables:220544, code:221000, padding:8376 free for local variables:74368
teensy_size: RAM2: variables:328512 free for malloc/new:195776


Now install 1.58.1 and re-compile. Here are the results:

Memory Usage on Teensy 4.1:
FLASH: code:240068, data:144144, headers:8996 free for files:7733256
RAM1: variables:228320, code:236520, padding:25624 free for local variables:33824
RAM2: variables:328544 free for malloc/new:195744

Note the "free for local variables" decreases about 40kB comparing 1.56.1 to 1.58.1.

Regards,
Greg



One of my Betas is running 2.10 and 1.58.2 on Linux and reports a 40K increase in stack usage versus 1.57. On Windows it's less dramatic, about 10K, but still significant. I do not have a Linux machine so I cannot verify, but he's a good EE guy (retired RF Engineer from Motorola) and I trust what he says. Does anyone else see these kinds of change on Windows or Linux. Anything in the libraries that might cause this?
 
Looks like data grew 8K and code grew 15K with the change in Teensy toolset in the updated TD - that code growth caused use of another 32KB RAM1 chunk and the padding went from 8K to 25K bytes.

If the code shrunk 7K then 32KB would be returned for memory usage.

Trying a build for 'smallest code' might make a big difference.
 
Big Difference with Smallest Code

Setting for smallest code in IDE with TeensyDuino 1.58.1:

Memory Usage on Teensy 4.1:
FLASH: code:187388, data:139788, headers:8688 free for files:7790600
RAM1: variables:223072, code:184152, padding:12456 free for local variables:104608
RAM2: variables:328544 free for malloc/new:195744


Looks like data grew 8K and code grew 15K with the change in Teensy toolset in the updated TD - that code growth caused use of another 32KB RAM1 chunk and the padding went from 8K to 25K bytes.

If the code shrunk 7K then 32KB would be returned for memory usage.

Trying a build for 'smallest code' might make a big difference.
 
Setting for smallest code in IDE with TeensyDuino 1.58.1:

Memory Usage on Teensy 4.1:
FLASH: code:187388, data:139788, headers:8688 free for files:7790600
RAM1: variables:223072, code:184152, padding:12456 free for local variables:104608
RAM2: variables:328544 free for malloc/new:195744

That is a significant difference! Does the code involved have any demand or measure for speed of execution? That is: is there any appearance the code has slowed or changed in any measurable way?
 
No luck with smallest code

Smallest code is not successful. There is no detectable activity. I should see the display light up with a message. Nothing at all happens. Also, there was some possible port drops. I've never seen the port drop like it did several times. I'm just not sure the upload happens properly.

That is a significant difference! Does the code involved have any demand or measure for speed of execution? That is: is there any appearance the code has slowed or changed in any measurable way?
 
EconjackFileMenu.jpg
This is a screenshot.
 
I've been trying different things, including a new download, to get beyond the "File-Exit" problem illustrated in Post #18...no joy. 1.8.19 still works, however. All of this seems very odd to me.
 
The screenshot is very odd to me too. I've never seen the IDE do anything like that.

Maybe if you fully delete the IDE and setting and then reinstall, it might magically work?

I see in msg #1 you're using Windows. On Windows the settings are stored in a folder named Arduino15 inside a hidden LocalData folder. I personally don't use Windows much (every time I've had to access LocalData it's taken me some fiddling and fumbling), but if you can't find the hidden LocalData folder I'm sure people who know Windows can help. First quit the IDE, then delete that Arduino15 folder, so all of the old IDE stuff is gone. Data also usually gets saved in Documents/Arduino, though that stuff is less likely to cause the software to do anything strange.
 
I've been trying different things, including a new download, to get beyond the "File-Exit" problem illustrated in Post #18...no joy. 1.8.19 still works, however. All of this seems very odd to me.
Me too.

In most cases like this, I would recommend that you probably also post up on the Arduino forum as well. https://forum.arduino.cc/c/software/ide-2-x/93/l/latest
You might include additional information as well, like what Linux and version are you running? AppImage or Zip format? Over there they will probably have you try to run the IDE from a terminal window or the like, maybe turning on some options and then posting the debug output.

Note: it is not just your tool menu, it looks like all of the menus are screwed up. That is your show: File, Edit, view, window, help menus.

But normally we have:
Screenshot.png
File, Edit, Sketch, Tools, Hep

If it were me, I would also probably hit it with large hammer. For example as Paul mentioned, delete your current 2.1 install, clean out your Temp folder, at least anything with the name including arduino, and the *.clangd files.

I would also clear out some of their cached information, like I need to do when I change a boards.txt or platform.txt file.
(issue: https://github.com/arduino/arduino-ide/issues/1030)
In the case of Linux it says the directory. ~/.config/arduino-ide/
And then I would try to reinstall.

But before that I would check the Arduino forum and see if someone posted about this and if not post...

Edit: looks like you have posted:
https://forum.arduino.cc/t/2-10-lack-of-file-menu/1126014
 
2.1 is now up and running! I'm sure I uninstalled/installed the IDE and the Teensyduino software patch a dozen times, but it now appears to be working. Alas, I took the one-equation-two-unknowns approach out of sheer frustration, so I cannot pinpoint the change that produced the resolution. I'm guessing it was one of the 3 things sterretje suggested:

C:\Users\yourUsername\.arduinoIDE\arduino-cli.yaml
C:\Users\yourUsername\.arduinoIDE\settings.json
Everything in C:\Users\yourUsername\AppData\Local\Arduino15

as it started to work after those changes.

I do want to thank those (sterretje, ptillischm kurtE) who put in the effort to help me; it is sincerely appreciated.
 
Back
Top