autorelease Questions
3
Solved
I know memory management in iOS is tricky subject to newbies like me, but I was hoping for a clear explanation here on stackoverflow which I could not find anywhere else.
So, pretend I have a pro...
Fanelli asked 3/9, 2011 at 13:13
3
Solved
I have an NSTimer firing at 60 fps. It updates a C++ model and then draws via Quartz 2D. This works well except memory accumulates quickly even though I am not allocating anything. Instruments repo...
Kalila asked 13/7, 2011 at 22:38
1
Solved
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...
Apennines asked 20/5, 2011 at 8:43
2
Solved
I see in some sample code that autorelease is used. I am not familiar with the instances when this is required. For example, if I create an annotation object
Header file
@interface someViewContro...
Cab asked 19/5, 2011 at 7:33
1
Solved
I wrote a class for declaratively describing a sequence of UIView animations. My method takes a vararg of animation blocks and puts them in an array. So in my loop I want to do this:
[animations a...
Frasier asked 2/5, 2011 at 8:24
7
Solved
I have been looking through the questions asked on StackOverflow, but there are so many about memory management in Objective-C that I couldn't find the answer I was looking for.
The question is if...
Tbar asked 18/7, 2009 at 15:20
2
Solved
I am learning memory management, but I don't really understand why I should implement my attribute getter like this:
-(Weapon*)myWeapon
{
[myWeapon retain];
[myWeapon autorelease];
return myWea...
Jackscrew asked 12/2, 2011 at 23:47
1
Solved
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release...
Aba asked 9/2, 2011 at 23:52
5
Solved
I'm attempting to narrow down a bug to a minimum reproducible case and found something odd.
Consider this code:
static NSString *staticString = nil;
int main (int argc, const char * argv[]) {
NS...
Frohman asked 18/1, 2011 at 22:42
5
Solved
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 deve...
Halberd asked 5/3, 2009 at 4:37
3
Solved
I am using custom delegate objects to do some cleanup tasks after a request finishes. ASIHTTPRequest doesn't retain delegates so I can't autorelease them. Right now this is how I am allocating and ...
Turnout asked 5/1, 2011 at 22:5
4
Solved
I use the following code to draw a subimage
UIImage* subIm = getSubImage( large, rect );
[subIm drawInRect:self.bounds];
where getSubImage is defined as follows
UIImage* getSubImage(UIImage* u...
Ransome asked 28/12, 2010 at 13:21
1
Solved
When I need an array for temporary use, what's the difference between these:
1:
NSMutableArray *stuff = [[NSMutableArray alloc] init];
// use the array
[stuff release];
2:
NSMutableArray *stuf...
Anachronistic asked 2/11, 2010 at 11:27
4
Solved
In the developer documentation, it says:
If your application or thread is long-lived and potentially generates a lot of autoreleased objects, you should periodically drain and create autorelease ...
Antoninaantonino asked 27/9, 2010 at 19:17
2
I am calling a method that goes in a background thread:
[self performSelectorInBackground:@selector(loadViewControllerWithIndex:) withObject:[NSNumber numberWithInt:viewControllerIndex]];
then, ...
Rizas asked 30/5, 2009 at 10:16
3
Solved
i.e. would cause the object to be released immediately and not have to be released by the pool if I did this?
[[NSArray arrayWithCapacity:100] release];
Can't find a clear explanation in the doc...
Altruist asked 4/5, 2010 at 23:54
4
Solved
I have a task that takes a rather long time and should run in the background. According to the documentation, this can be done using an NSOperationQueue. However, I do not want to keep a class-glob...
Antipas asked 23/3, 2010 at 15:3
2
Solved
I am new in objective-c and I am trying to understand memory management to get it right.
After reading the excellent
Memory Management Programming Guide for Cocoa by apple my only concern is when ...
Phthisic asked 23/3, 2010 at 8:2
2
Solved
I am new to objective c and am trying to understand how/when autorelease is called. I understand the simple use case of:
- (void) foo {
Bar *b = [[[Bar alloc] init] autorelease];
[self doSomethi...
Spermatium asked 17/2, 2010 at 16:6
2
Solved
I'm getting a a bit annoyed about some objects being autoreleased without me knowing. It's probably a good thing that they are, but if they are, I want to know. The documentation doesn't say which ...
Amylene asked 23/9, 2009 at 15:10
3
Solved
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...
Dyke asked 28/4, 2009 at 11:28
5
Solved
I understand you need to be careful with autorelease on iOS. I have a method that is returning an object it allocs which is needed by the caller, so in this situation -- as I understand it -- I nee...
Bibbye asked 23/3, 2009 at 13:32
© 2022 - 2024 — McMap. All rights reserved.