开发者

Release memory for object

开发者 https://www.devze.com 2023-02-05 13:25 出处:网络
I have read some book about release allocated object memory. some say: object = nil, some say: [object release];

I have read some book about release allocated object memory.

some say: object = nil,

some say: [object release];

I am confused, what is different, and which one is better?

If I set object = nil, I can see the object handler has been set from debugger. If I call [object release]; object handler still a bunch of number, which is address.

Is there anybody give me more information about memory release?

From Java point-view, I set object开发者_StackOverflow handler as null, that notify runtime to collect it. how about Objective-C.

Or which object need to set nil, which object needs to release.


Here's a link to a very thorough treatment of iPhone Memory Management:


I believe if you set your object to null you're explicitly setting it to a value (null in this case). Whereas if you release it, you're telling the system you're finished with that chunk of memory and it handles it as it sees fit, in your example that means setting it to a garbage value.

0

精彩评论

暂无评论...
验证码 换一张
取 消