dealloc

What explains best the difference between [myVar dealloc] and [myVar release]?

I think I know the difference, but don't know how to explain that correctly. dealloc removes the memory reserved by that variable totally and immediately. release decrements the retain counter of that variable's memory by -1. if it was 1, then it's 0, so it would have the same effect as dealloc in that moment. is that right? or is the...

Should I release a IBOultet in my dealloc function?

If I have something like this in my .h file: @property (nonatomic,retain) IBOutlet UIButton *btnHelp; Should I release it in the dealloc function of the .m file? ...

Valid use of accessors in init and dealloc methods?

I've heard now from several sources (stackoverflow.com, cocoa-dev, the documentation, blogs, etc) that it is "wrong" to use accessors and settings (foo, setFoo:) in your init and dealloc methods. I understand that there is there is a remote possibility of confusing other objects that are observing the property if you do so. (a simple e...

Is there any advantage to deallocating objects owned by the UIApplicationDelegate?

Best practices aside, if I create an object that is owned by my UIApplicationDelegate class, and stays around the entire time the application runs, is there any real advantage to adding an [object release] statement in the UIApplicationDelegate's dealloc method? The only time that would be called is when the user is shutting down the ...

Printing Instance ID to NSLog?

In the dealloc method for a class how would I print out the ID (or some other unique identifier) for the instance being deallocated? - (void)dealloc { NSLog(@"_deallocing: ??"); [super dealloc]; } Is this possible? I am just trying to get a little more feedback in the console as an aid to learning. many thanks -gary- ...

When are released objects finally destroyed?

When you release an object in Objective-C (assuming its release count is 1) its release count is decremented to 0 and the dealloc method called. Is the object destroyed right there and then after the [super dealloc], or is it added to the pool and destroyed when the pool is drained? I would assume that released objects are destroyed at ...

Is it possible to check whether an OpenGL ES texture on iPhone has been truly deallocated?

The manual just instructed you to write: glDeleteTextures(1, &GLtexture); and claims that the texture will be deleted. iPhone has scarce memory and I want to ensure that these textures are truly released. The Leaks instrument cannot detect this, and frankly, I am a bit worried. I do really want to make sure that the textures are rea...

Inheritance release order?

In my current test I have a class "PlanetClass" that inherits from "celestialClass". My question is when I release my "PlanetClass" object it goes through both dealloc methods, firstly releasing the Planet object and then the Celestial object. I added the dealloc to celestial to make sure I could release the iVar "bodyName", I think I ha...

objective-c object not getting dealloc:ed

I've got an issue with an object not being deallocated in objective-c. I'm pretty certain this is because it is being retained somewhere, but I don't know where (checking retainCount where it ought to be 0 returns a 1). I've gone through my code many times but fail to see what's retaining it that I don't release. Might even be a bug in t...

iPhone - dealloc subview UIViewController when removeFromSuperview

I have several buttons on my main UIViewController (main menu) that creates and adds a subview UIViewController on top of the main menu. When I remove the subview the memory from that controller is not released. How can I release that subviews memory instantly? Does anyone have an example? This would solve all my problems! Thanks in...

iPhone - Multiple UIViewControllers Release

My main UIViewController, (PMGameViewController.h), is the file which my apps delegate calls. There are several buttons on my main UIViewController (PMGameViewController.m). When a button is pressed I do an insertSuvbiew and attach another UIViewController on top. When the mini game is over I simply do a removeFromSubview. This rem...

iPhone - dealloc - Release vs. nil

Wondering if someone with experience could possibly explain this a bit more. I have seen examples of... [view release]; view = nil; ....inside the (void) dealloc. What is the difference and is one better then the other? What is the best way? When doing retainCount testing I have personally seen nil drop a count from 3 to 0 for me...

iphone app with multiple views/subviews: memory is not being deallocated

Hello I have an iPhone application that loads succesive views in a framework based on the one explained in this link (basically a main ViewController that loads/removes additional views with a displayView method). In my application I am using NIBs (the example link uses coded views) though so each of my ViewControllers has its accompany...

Objective C - Where do you dealloc global static variables?

Or, what is the opposite of +(void)initialize? Here's my situation: I have a class Unit, whose -(id)initWithName: function takes data from a global NSDictionary, which is created lazily, defined in the Unit.m file as: static NSMutableDictionary *unitLibrary = nil; Where do I call [unitLibrary release]? ...

Trouble Finding a Memory Leak

Hey everyone, i am having trouble finding a memory leak. all off my retain counts = 0 when i dealloc them but still I am flagging up a leak from the following bit of code: - (GKSession *) peerPickerController:(GKPeerPickerController *)picker sessionForConnectionType:(GKPeerPickerConnectionType)type { inSession = [[GKSession alloc] initW...

iPhone Memory Management: No Need to Clean Up and Release Retained Objects on App Quit?

Is the following true? When the app is about to quit, it's not necessary to clean up the memory by calling release on all your retained objects, because the iPhone OS will reclaim the memory it allocated for your app when you launched it. This is faster and safer than rely on the apps to correctly clean up after thems...

"Swapping" a UIView Instance variable - cannot dealloc "previous" view

I want to organize somehow my iPhone game's level-views, but I simply cannot (without expanding Object Allocations). I made a really "skeleton" of my code (this game has 2 levels, the goal is to release the iPhone display). I just cannot dealloc the previous level, so Instrunments shows incrementing BGTangramLevel instances. Please, tak...

Multiple UIViews, dealloc and retain

I have a small application for displaying several UIImageViews in a UIScroller in a similar fashion to the Photo app. I have a TableView which, when i select an item, parses an XML document of photos (added to an array) and adds a UIViewController which displays the images. The problem is I have a tab bar controller which, upon clickin...

Several UIImageViews in UIScrollView and crashes

I have a problem with a photo viewing application I've written. I have a UITabBarController with a UINavigationController inside. The UINavigationController initially displays a UITableView. On selection it pushes another UIViewController (Individual photo album) along with an NSArray of photos. This Controller contains a UIScrollVie...

any difference between these two dealloc methods?

So i'm overriding dealloc method because the object is a composite object made up of one other object. I originally had this dealloc method: -(id) dealloc; // Override to release the Rectangle object’s memory { [rect release]; [super dealloc]; return self; } After looking in the book I saw another answer: { [rect rel...