while i was working on something entirly different i came to think about RAM and stuff…
From what i see there are several functions which seem to use ram, no matter thay are being used or not in the program, like millis() or micros().
Now my tired mind made up the idea that those function might even consume (relativly) big amounts of ram as millis is a unsigned long (4Byte?) and micros should be something similar…
So my question is - would it be a good idea to have some sort of compiler option to turn those functions off or are they used in a manner i do not know and therefore vital for the whole arduino process that is running?
You can look at the amount of ram used by each module with the avr-size command in the sketch build directory:
/Applications/arduino/Arduino-0012/hardware/tools/avr/bin/avr-size *.elf *.o
text data bss dec hex filename
968 0 12 980 3d4 Blink.elf
816 0 150 966 3c6 HardwareSerial.cpp.o
1098 2 0 1100 44c Print.cpp.o
66 0 0 66 42 Temporary_2147_578.cpp.o
288 0 4 292 124 WInterrupts.c.o
306 0 0 306 132 WMath.cpp.o
90 0 0 90 5a pins_arduino.c.o
566 0 12 578 242 wiring.c.o
244 1 0 245 f5 wiring_analog.c.o
376 0 0 376 178 wiring_digital.c.o
258 0 0 258 102 wiring_pulse.c.o
366 0 4 370 172 wiring_serial.c.o
130 0 0 130 82 wiring_shift.c.o
“data” is initialized values, “bss” is uninitialized ram. Some of the RAM listed as used in the .o files will not end up used in the sketch itself because that Module is not used (note that Blink.elf, which is the entire sketch for Blink, uses less ram than the sum of its parts.) This gives you an idea of max memory that will be consumed, though.
The 12 to 16 bytes consumed by the arduino core is not considered “big”, even on a cpu with 1k. The 150 bytes for HardwareSerial, on the other hand, had been coming into some question (note that arduino13 and arduino14 had a “bug” that caused the HardwareSerial memory to be included in a sketch whether you used it or not. This is fixed in arduino15.)
The 12 bytes used in wiring.c (you can look at the source) are all for the timing functions. You can simplify them, or get rid of them entirely, but they are pretty basic to the core of the Arduino environment. You might as well program in strait C.