How to Keep C++ Binaries Small - Techniques for C++ Optimization
summary
Shows concrete levers and measured wins: a global array initialized to ones produces ~100 KB while changing to zero collapses it to ~16 KB (99K → 16K by zero-init); switching a class to polymorphic pays a big fixed cost—adding the first virtual inflates the binary by roughly 150 KB (first virtual adds ~150KB). Uses inspect tools like size, objdump, nm, mcboy and flags like -Os/-Oz, -flto, -fdata-sections -ffunction-sections + --gc-sections, -fno-rtti/-fno-exceptions and shows they often beat micro-refactors. Measure everything in CI.
AI-written summary · about
chapters (6)
- 0:00Introduction
- 23:33Coding practices for size
- 1:00:14Special member functions
- 1:50:58Compiler and linker settings
- 2:07:59Removing RTTI and exceptions
- 2:21:02Summary
related talks
26mDebloating Software through Piece-Wise Compilation and Loading
49mWriting better code with help from Qt and the compiler
01h 01mLarge Scale C++ with Modules: What You Should Know
55mIdentifying Common Code Smells (In C++)
27mInfiltrating a Code Base: Moving Toward a Better C
01h 21mEmpirically Measuring, & Reducing, C++’s Accidental Complexity
01h 07mSmall Is Beautiful
56mWrite Fast Code Like a Native
