There is no way of doing this in Standard C++, and very few frameworks support anything like it. The reason is fairly simple - as you have observed, an object may contain pointers, and those pointers may point to further objects that contain pointers,
and so on. And even when you get to the end of the pointer chain, there is no general method to find out how much memory a pointer points to.
So, you need to find another way to solve your problem, which I don't believe is the right problem to solve in the first place.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…