Xcode - 实时查看内存数据


实时查看内存数据

1 - 断点:Debug\Debug Workflow\View Memory

 1 #import 
 2 @interface Student : NSObject{
 3     @public
 4     int _no;
 5     int _age;
 6 }
 7 
 8 @end
 9 
10 @implementation Student
11 
12 @end
13 
14 int main(int argc, const char * argv[]) {
15     
16     Student *stu = [[Student alloc] init];
17     stu->_no = 4;
18     stu->_age = 5;
19 
20     NSLog(@"%@",stu);
21     return 0;
22     
23 }

我们在第 20行打上断点,stu内分布状况如图所示:获取前 16个字节,从右至左读取

2 - 使用 lldb指令,同样要打上断点

① 常用指令

② 如何使用:_no = 4 最后修改成了 8