Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

Thread: Memory Leaks..!
View Single Post
Old 07-03-2009, 03:05 PM   #13 (permalink)
smasher
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by _mubashir View Post
I have put NSLog in dealloc and it gets called fine. Yes I am releasing arrProvider (NSMutableArray) in the appdelegate's dealloc. I am getting leak on Provider object as well so I assume its leaking. One thing I need to know is I have arrProvider filled with Provider objects, now do I need to release all Provider objects before releasing arrProvider or I can just release it ?
When the array gets deallocated, every object in the array gets a release message. This means that if you followed the rules so that (1) the array has a retainCount of one and (2) every object in the array has a retaincount of one, calling [array release] will deallocate both the array and every object inside. You should not need to remove them from the array or call release on them before releasing the array.

If you're getting a leak on a Provider object, hunt that down first - if you leak a Provider, every object in that provider may get leaked even if you followed the rules inside the Provider class.

Quote:
YES its shows malloc, release, malloc and then autorelease. autorelease is not cleaning anything so its becomes a leak.
Hunt down the Provider leak first. "malloc, release, malloc, autorelease" is the history of two different objects. The first object's history was "malloc, release" - it was released properly and destroyed. Then the address was reused for a second object, which as you said is getting leaked. I would expect "autorelease" to be followed by "release" when the autorelease pool clears; not sure why it isn't.

You will be an expert in the leaks tool by the time you are done.

Quote:
I also need to know the View that we push in the navigation controller - do we need to release it too?
I am autoreleasing it like this
Code:
Providers *ProviderView = [[[Providers alloc] CustomInitWithNibName:@"Providers" bundle:nil bIsProvider:YES] autorelease];

    [self.navigationController pushViewController:ProviderView animated:YES];
Not sure, someone else will have to answer - I haven't done navigationControllers for a while.
__________________

Free Games!
smasher is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,744
Threads: 89,200
Posts: 380,559
Top Poster: BrianSlick (7,129)
Welcome to our newest member, Dani77
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:10 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.