Is it Arduino IDE intelligent ?

Is it Arduino IDE intelligent for optimize and remove unused function in compile time?

Hello

when I compile program using this headers:
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include "Dns.h"
#include <Wire.h>
#include <RTClib.h>
#include <SPI.h>
#include <SD.h>
#include <LiquidCrystal.h>

for function of: NTP, RTC, Onewire (Multi DS18B20), LCD and Ethernet / SD (toggle switch in using time)
to get data from Internet web service and send data to web service (+ log it on SD for backup)
I get memory error
so I need to remove unused function or find other way to pass memory problem.
another Idea is split program between 2 Arduino to separate program and create communicate between together.

how can do it?

Thanks
Armen

You included SPI.h twice. Perhaps there are other errors in your code as well.
How much memory do you need to trim? Adding a second Arduino seems a bit much ...

In answer to your original question, the IDE does not normally compile uncalled code.

Hi Yes you are right about duplicate
Thanks
but it's not different in memory size after I remove it

Sketch uses 16,212 bytes (50%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,061 bytes (51%) of dynamic memory, leaving 987 bytes for local

After remove duplicate

Sketch uses 16,212 bytes (50%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,061 bytes (51%) of dynamic memory, leaving 987 bytes for local variables. Maximum is 2,048 bytes.

The linker removes unused functions.

And I don't see your problem with roughly 50% (both program memory and RAM) usage only. Unless you do funny things in your functions.

If you use fixed text (e.g. Serial.println("hallo");), consider the use of the F macro (Serial.println(F("hallo"));); this will move the fixed text to program memory and free some RAM.

Any fixed data can be moved to program memory using PROGMEM

Please, post all of your code, so we can see where you are spending your RAM.
Which kind of memory error are you having? You have to be more explicit.

And which Arduino are you using? My project is almost like yours, and I had to move it to a mega, that is a much better choice than using 2 Arduino's. But it's probably not the case for the time being.

As already mentioned, ~50% for global variables it's perfectly fine, you are probably doing something wrong along the way. If I had to guess, I would bet you are printing string literals without the F() macro.

The linker (actually part of the GCC compiler and not an Arduino product at all) is astoundingly good at removing un-used functions. You will have a very hard time beating it. With some effort, you can shave a few bytes off library functions by re-writing them to remove unwanted features. But it is almost never worth the effort.

50% program and 50% dynamic sounds pretty good. There must be a problem elsewhere in your sketch. Are you trying to dynamically create large arrays of floats or ints?

Are you trying to dynamically create large arrays of floats or ints?

I thought C++ didn't support that? They had to be declared at compile time?

I thought C++ didn't support that?

C++ is a superset of C. C supports malloc() and free(). C++ adds new and delete.

MorganS:
The linker (actually part of the GCC compiler and not an Arduino product at all) is astoundingly good at removing un-used functions. You will have a very hard time beating it.

It can depend on the code.
There are some things that trip it up.
Things like ISRs and certain types of C++ virtual functions.

For example if you include <Wire.h> you will get most of the Wire library code linked in even if there is not a single reference to the any of the library code in the sketch.

--- bill