autorelease

What's the difference between sending -release or -drain to an Autorelease Pool?

会有一股神秘感。 提交于 2019-11-27 03:48:04
问题 In many Books and on many Sites I see -drain. Well, for an Autorelease Pool that sounds cool. But does it do anything other than an release? I would guess -drain just makes the Pool to -release all it's objects, without releasing the Pool itself. Just a guess. 回答1: Note that the comments on oxigen's answer saying that -drain does not release the NSAutoreleasePool are not correct. The documentation for NSAutoreleasePool clearly says that -drain releases (and thus destroys) the

Is there a way to create an NSDecimal without using NSNumber and creating autoreleased objects?

痞子三分冷 提交于 2019-11-26 20:25:00
问题 I am carrying out a number of calculations using NSDecimal and am creating each NSDecimal struct using the following technique: [[NSNumber numberWithFloat:kFloatConstant] decimalValue] I am using NSDecimal to avoid using autoreleased NSDecimalNumber objects (if the NSDecimalNumber approach to accurate calculations is used). However it seems that the NSNumber creation mechanism also returns an autoreleased NSNumber from which the decimal value is extracted. Is there a way to create an

What is the difference between releasing and autoreleasing?

老子叫甜甜 提交于 2019-11-26 19:54:46
问题 I still have some unclear understand about release and autorelease. What are the difference between both of them? I have this code. For facebook connection. I crash it sometimes when I go to Facebook login, I doubting maybe it is because I don't release the object nicely.? Thanks for any helps if (_session.isConnected) { [_session logout]; } else { FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:_session] autorelease]; [dialog show]; } 回答1: The Memory Management Programming

How to find the cause of a malloc “double free” error?

流过昼夜 提交于 2019-11-26 19:22:39
I'm programming an application in Objective-C and I'm getting this error: MyApp(2121,0xb0185000) malloc: *** error for object 0x1068310: double free *** set a breakpoint in malloc_error_break to debug It is happening when I release an NSAutoreleasePool and I can't figure out what object I'm releasing twice. How do I set his breakpoint? Is there a way to know what is this "object 0x1068310"? Frank Krueger You'll find out what the object is when you break in the debugger. Just look up the call stack and you will find where you free it. That will tell you which object it is. The easiest way

Does @“some text” give an autoreleased or retain 1 object back?

Deadly 提交于 2019-11-26 14:09:31
问题 Given this code: // Initialize string NSString *name = @"Franzi"; @"" macro creates a NSString with given text (here the name Franzi) and a RETAIN COUNT OF 1? So @"" gives an NSString with have to be released or not? Am I responsible for this object? Second code example then confuses me, even though I am using it that way: NSSting *message; message = [NSString stringWithFormat:@"Hello @%!",name]; //message = [NSString stringWithFormat:@"Hello Girl!"]; So message gets released in next run loop

Why is autorelease especially dangerous/expensive for iPhone applications?

怎甘沉沦 提交于 2019-11-26 13:53:15
问题 I'm looking for a primary source (or a really good explanation) to back up the claim that the use of autorelease is dangerous or overly expensive when writing software for the iPhone. Several developers make this claim, and I have even heard that Apple does not recommend it, but I have not been able to turn up any concrete sources to back it up. SO references: autorelease-iphone Why does this create a memory leak (iPhone)? Note: I can see, from a conceptual point of view, that autorelease is

How to find the cause of a malloc “double free” error?

旧街凉风 提交于 2019-11-26 06:57:27
问题 I\'m programming an application in Objective-C and I\'m getting this error: MyApp(2121,0xb0185000) malloc: *** error for object 0x1068310: double free *** set a breakpoint in malloc_error_break to debug It is happening when I release an NSAutoreleasePool and I can\'t figure out what object I\'m releasing twice. How do I set his breakpoint? Is there a way to know what is this \"object 0x1068310\"? 回答1: You'll find out what the object is when you break in the debugger. Just look up the call