Why does the sketch size depends on selected board?

The sketch size of my project is 9.4k when compiled for the Mega 2560 and only 7.5k for the Mini Pro ATmega328. What is behind this huge difference?

The Mega has 4 serial ports. That means 4 input buffers and 4 output buffers and 4 instance of the hardware serial class. Among other things that were mentioned in the thread when this question was asked last week.

Thanks. Is there any possibly to instruct the compiler not to install all those superfluous classes?

Charm:
Thanks. Is there any possibly to instruct the compiler not to install all those superfluous classes?

It's been requested to see if the serial library can be made more 'flexible', we will have to wait and see.

Thanks. Is there any possibly to instruct the compiler not to install all those superfluous classes?

What makes them superfluous? You seem to expect the compiler to know whether you are using the Serial instances.

The mega has a larger bootloader, no?

The mega has a larger bootloader, no?

Which reduces code space, but is not included in the sketch size.