libraries wasting RAM

Hi,
compilation of my project on a Mega2560 leaves about 2 kB RAM for local variables and shows a warning that RAM memory might be low.
This is valid on my PC for development of sketches which is up to date with all libraries.

Compilation of this project on a PC with a somewhat elder IDE (about 6 months) leaves more than 3 kB RAM for local variables.

Libraries used are Arduino.h, stdio.h, string.h, SPI.h, Wire.h, EEPROM.h.
Some of them, or all of them, seem to waste RAM with the latest versions. This is most critical for the Arduino world because the controllers usually only have very limited RAM.

Has somebody an idea what header files are using so much RAM?

I am using IDE 1.6.12. Will later IDE versions improve this situation?

SupArdu

SupArdu:
a somewhat elder IDE (about 6 months)

Which version?

Note that the IDE version is actually not directly relevant to sketch size. In this case it is solely the Arduino AVR Boards version that matters (can be checked via Tools > Board > Boards Manager). This is somewhat linked to the IDE version since a specific Arduino AVR Boards version is bundled with each IDE release. However, Boards Manager allows you to install a different Arduino AVR Boards version and at that point the IDE version becomes irrelevant.

SupArdu:
Has somebody an idea what header files are using so much RAM?

Take the scientific approach and run some tests to narrow it down.

SupArdu:
I am using IDE 1.6.12. Will later IDE versions improve this situation?

Possibly. There have been some changes in the Arduino AVR Boards toolchain since then and possibly some to the libraries. Likely the most significant differences you will see are between Arduino IDE 1.6.9/Arduino AVR Boards 1.6.11 and older and Arduino IDE 1.6.10/Arduino AVR Boards 1.6.12 and newer since there were very significant changes to the toolchain and compilation flags in Arduino AVR Boards 1.6.12. Note that the Arduino AVR Boards versions do not match the Arduino IDE version they are bundled with.

Sorry, I told you some wrong information.
On both PCs the IDE version is 1.6.12.

But the boards versions for the Mega2560 are different. The main PC has version 1.6.20 installed and the elder one has 1.6.14 installed.
I don't know the versions of the libraries. But I am sure that between boards version 1.6.14 and 1.6.20 there have been some updates for the libraries too.

I will do some tests as you suggested.

Thank you for your tips

SupArdu

It's good you're using the same IDE version on each so you know that's not a factor. Both those versions of Arduino AVR Boards are using LTO so that's not the cause. You have multiple variables to consider:

  • Versions of the libraries.
  • Versions of the core libraries. (located in the cores/arduino subfolder of the Arduino AVR Boards hardware package)
  • Version of the toolchain.

You can try to narrow the source of the discrepancy down by swapping libraries and core between the hardware package versions. For example, if you move the library(s) from 1.6.20 to 1.6.14 and there is no change in compile size then you know changes to the library(s) were not the cause. Same with the core library. If you're working with multiple libraries and find that the libraries versions cause a difference then you can try them one at a time. You can also do diffs of the source files or check the commit history on GitHub to see what changed between versions. I'd leave the toolchain in place because that's a little more complicated to swap than the other two variables.