Abstract: Use whenever you have NARC?

I know this question looks like a hoax: I checked, but thatโ€™s not

Speaking about NARC, the author of this blog says : "Personally, I like to immediately auto-update everything that I NARC-ed on the same line." This completely contradicts all the examples that I saw on the Apple website and in books where autorelease is used only when the object must be returned and cannot be immediately released. In general, the idea is that it autoreleaseworks intensively with memory and can align your program (although it does a code cleaner). From Appress Getting Started iPhone 3:

These objects may have an effect on the memory of your application footprint. It's ok to use autorelease, but try to use it only when you really need to, and not just save the input of a line or two from the code.

I do not ask if auto-advertising is worse than the explicitly causing release (this), but rather:

In most โ€œnormalโ€ situations on iPhone, how bad is it to replace a later version with an earlier auto-advertisement (in the same method)? Furthermore, in what situations would this be absolutely unacceptable for this?


I assume that, compared to using the garbage collector (as MonoTouch applications do successfully), the abstract is unlikely to make a dent in the memory area, and that Vincent advises it correctly and can do for cleaner code and less random memory leaks.

+4
2

, . . . , , , , , .

( , , /), , .

, , /. , , .

, , , ( , , ). , , , , .

autorelease , . , : , , , .

+2

autorelease, , .

autorelease:

for (int i=0;i<1000;i++) {
    NSString *s = [[[NSString alloc] init] autorelease];
}

// at this point, there are 1,000 unreleased string objects in memory

release:

for (int i=0;i<1000;i++) {
    NSString *s = [[NSString alloc] init];

    [s release];
}

// at this point, no string objects are "alive"

, .

+3

All Articles