After compiling, sketch sizes don't add up

I am working through some examples to familiarize myself with certain libraries and how the Spark Cores work. Currently, I am using the libraries for MCP23017 I/O port expander and 16x2 I2C RGB LCD found at this GitHub repository owned by @peekay123.

I am working in the web-based IDE and when I compile, I look at the Ⓘ symbol and click on it to see how my resources look. What I saw doesn’t make a whole lot of sense.

It says that I have used:

Flash used: 83872/110592 75.8%
RAM used: 10284/20480 50.2%

I looked at the GitHub and looked at the file sizes for each .cpp and .h file. These are the file sizes:

MCP23017.cpp 8kb
MCP23017.h 3kb
Adafruit_RGBLCD.cpp 12kb
Adafruit_RGBLCD.h 4kb
My own sketch.ino 3kb

which total 30kb.

The STM32 on the Spark Core has 128kb of Flash memory (110kb actually usable).

Why am I seeing that it is taking 2.8x the amount of space than what it should be using? I understand there is a little overhead but not at that much of a cost!

What gives?

@eavery, the COMPILED final binary file size has nothing to do with the file size of its components source files. When you compile for the Core (unlike the Photon and Electron), the file includes BOTH the system firmware and the user app in a single image (called a monolithic image). This is why the flash used appears so large. The same applies with the RAM since the number reflects the RAM used by both the system firmware and the user app. As you can see, the Core has a lot less working space (Flash/RAM) then the newer Photon.


Wow. That doesn’t leave much wiggle-room for sketches. I didn’t realize the firmware would take up that much, too.

Would you happen to know right off-hand the usable space for Spark Cores and Particle Photons?

I may have to go and grab some Photons–half as cheap and twice the abilities.