Applications compiled on MacOS use an instance of std::string::~string() linked in from the C++ standard library. This means that std::string lacks annotates.
Take the following program as an example:
#include <string>
#include <vector>
struct my_object {
std::string s;
std::vector<char> v;
template <size_t N>
my_object(char const (&cstr)[N]) : s(cstr)
, v(cstr, cstr + N) {}
};
int main() { my_object a = "01234556789 this is a string that's too big for SSO etc"; }
If we dump out the stats for my_object, we see this:
// Totals for my_object sizeof=48 bytes
// └── 112 bytes across 2 allocs and 1 instance
struct my_object
{
std::string s;
std::vector<char> v; // 56 bytes across 1 alloc : std::vector<char>
~my_object();
// directly owned (or unannotated):
// └── 56 bytes across 1 alloc
};
Both my_object::s and my_object::v should show 56 bytes, but only v has recorded bytes.
Since std::string's destructor isn't annotated, the 56 bytes owned by my_object::s are instead treated as directly owned.
Applications compiled on MacOS use an instance of
std::string::~string()linked in from the C++ standard library. This means thatstd::stringlacks annotates.Take the following program as an example:
If we dump out the stats for
my_object, we see this:Both
my_object::sandmy_object::vshould show 56 bytes, but onlyvhas recorded bytes.Since
std::string's destructor isn't annotated, the 56 bytes owned bymy_object::sare instead treated as directly owned.