Heap和stack 地址
源码:
__block int val = 10;
int *p = &val;
NSLog(@"%d address is :%p",val,&val);
block_blk blk = ^{
NSLog(@"%d address is :%p",++val,&val);
return val;
};
blk();
NSLog(@"%d address is :%p",val,&val);
NSLog(@"%d address is :%p",*p,p);
ARC运行结果:
10 address is :0x7fff5fbff908
11 address is :0x100103578
11 address is :0x100103578
10 address is :0x7fff5fbff908
Program ended with exit code: -1
MRC运行结果:
10 address is :0x7fff5fbff908
11 address is :0x7fff5fbff908
11 address is :0x7fff5fbff908
11 address is :0x7fff5fbff908
Program ended with exit code: -1
|
|