Loading…
Thursday September 17, 2026 15:15 - 16:15 MDT
Have you ever wondered why your C++ class suddenly doubled in size, or why reordering its members made it smaller? This talk introduces memory alignment in C++ from the ground up - what it is, why it is critical, and how compilers handle it under the hood. We’ll start from first principles: how modern CPUs read memory, the difference between aligned and unaligned access, and the performance costs of getting it wrong. Using benchmarks, we’ll see just how impactful misalignment can be. From there, we’ll dive into how compilers lay out data members in structs and classes, and how simple reordering can reduce memory footprint. Live coding examples will illustrate how padding is introduced and how tools like alignas, alignof, and std::align give you precise control. We’ll also look at packed data structures, which trade alignment guarantees for compactness - common in network protocols. While they can save space, they also introduce risks like undefined behavior when misused. Through real-world examples, you'll learn when packed structures make sense, and when they’re a hazard. By the end of the talk, you'll walk away with a solid intuition for alignment and the confidence to manage memory layout effectively in your programs.

Presenters
avatar for Sarthak Sehgal

Sarthak Sehgal

Tech Lead, Maven Securities
Sarthak Sehgal is a C++ Software Engineer at a high-frequency options market-making firm based in Chicago. He is passionate about low-level programming, performance optimization, and their applications in financial systems. Outside of work, he shares insights on C++ and finance on... Read More →
Thursday September 17, 2026 15:15 - 16:15 MDT
_3

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Share Modal

Share this link via

Or copy link