Object Introspection: A C++ Memory Profiler - Jonathan Haslam & Aditya Sarwade - CppCon 2023

Here is the meta description: Discover Object Introspection, a C++ library that measures memory footprints of complex objects without code modifications, providing accurate memory layout reconstruction and footprint calculation.

Key takeaways
  • Object Introspection (OI) is a library that provides a way to measure the memory footprint of complex C++ objects and their composition without requiring code modifications.
  • OI uses the ptrace interface to inject a breakpoint into a running process, execute a piece of code to capture memory occupancy attributes, and then resume the process.
  • It can reconstruct the exact memory layout of objects, including nested members and complex data structures, and accurately calculate their memory footprints.
  • OI uses debug information to infer the type hierarchy of an object and reconstruct it with the exact memory layout, allowing for accurate memory footprints to be calculated.
  • It can handle complex objects with nested members, complex data structures, and template classes, and can reconstruct objects even if they have been modified or finalized.
  • The library is designed to be pluggable and can be integrated with existing debuggers and profiling tools.
  • OI has been used to measure the memory footprints of complex objects in production environments and has helped identify memory-related issues and optimize memory usage.
  • The library is currently limited to working with objects that have not been inlined and does not support functions with data races.