Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.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, 02: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: 2,575
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.
__________________
smasher is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,288
Threads: 39,077
Posts: 171,356
Top Poster: smasher (2,575)
Welcome to our newest member, germainesluaus
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:38 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.