File Size and RAM Used

I am using a Pro Mini 3.3V 8Mhz board. My code uses the following libraries…

#include <EEPROM.h>
#include <Base64.h>
#include <SPI.h>
#include <Ethernet.h>
#include <SoftwareSerial.h>

I am debugging this project by using two instances of SoftwareSerial, One for debugging messages and one for Modbus Serial Data. (I wrote my own Modbus Serial code and did not use any library) Then the hardware serial is free to download and upload programs, I did not have any debugging data sent to the Hardware Serial during this phase.

I’ve now switched to my production board to test and have the SoftwareSerial library for my debugging messages and the Modbus comms are now connected to the Hardware Serial port.

When I compile the development board using 2 instances of SoftwareSerial, I reach 79% Rom and 64% Ram.

When I compile the production board using 1 instance of SoftwareSerial and the Hardware Serial, I compile to 82% Rom and 71% Ram

It just doesn’t compute in my head that this simple switch would change the file size so drastically. I’m just looking for an explanation as I think I can live with those numbers and still have room for more expansion later.


You're including an extra library with HardwareSerial. Without that instance of HatdwareSerial the compiler optimized away that library. Now you are including that code (the difference in ROM) and the buffer (the difference in RAM).

Do you still create two instances of SoftwareSerial? Remove the unused one, to preserve RAM.