主要的代码 64位系统下
@interface Person:NSObject
{//isa ---------- 8
int _age;//4
int _weight;//4 ---
int _height;//-----8
}
------------------------------------------------------------------
Person * p = [[Person alloc]init];
// 运算符 --编译时 就计算完成 类似 宏定义 ---例如 指针 64位 下就是输出 8
NSLog(@"%lu",sizeof(p));
// 实际占用的内存空间 --- Person这个对象里面3个成员变量 ,isa指针,根据结构体的内存对齐
// 输出 24
NSLog(@"%zu",class_getInstanceSize([Person class]));
// iOS 系统分配的空间 根据源码的看 结论是 16的倍数 最少 是 16; 输出 32 (距离24 最近的就是32)
NSLog(@"%zu",malloc_size((__bridge const void *)(p)));```