How do I find out at compile time how much of an STM32's Flash memory and dynamic memory (SRAM) is used up?
The information you need is all in the output from size (aka arm-none-eabi-size):

   text    data     bss     dec     hex filename
   2896      12    1588    4496    1190 STM32F103RB_Nucleo.elf



text is the size of all code in your application.
data is the size of initialized global variables. It counts against both flash memory and RAM, as it's copied from flash to RAM during startup.
bss is the size of global variables which are initialized to zero (or are uninitialized, and hence default to zero). They're stored in RAM only.
dec and hex are the sum of text + data + bss in decimal and hexadecimal. This value doesn't really mean much on a microcontroller, so it should be ignored. (In environments where a program must be loaded into memory before running, it would be the total memory footprint of the program.)


To calculate the RAM usage of your program, add the data and bss columns together.

To calculate the FLASH usage of your program, add text and data.