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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-18-2011, 11:39 PM   #1 (permalink)
Registered Member
 
aceiswild's Avatar
 
Join Date: Oct 2011
Location: Canada
Posts: 62
aceiswild is on a distinguished road
Default Potential Leak of an Object

Hey guys, i am getting a Potential Leak of an Object Allocated in the given code below. I am assuming i am not releasing something somewhere. There are no other leaks in my project besides this one. Do i need to declare something in my .M class?


AppDelegate .M:
Code:
 
#import "SliderPuzzleAppDelegate.h"
#import "SliderController.h"


@implementation SliderPuzzleDemoAppDelegate

@synthesize window;
@synthesize sliderController;
@synthesize vc;

- (void)applicationDidFinishLaunching:(UIApplication *)application {   

    self.sliderController = [[SliderController alloc] init];
    [window addSubview:sliderController.view];  <----- Potential Leak
    [window makeKeyAndVisible];

}

- (void)dealloc {
    [sliderController release];
    [window release];
    [super dealloc];

}


@end
__________________
Don't be a quitter! Never give up and keep pushing to succeed at the things you love!
aceiswild is offline   Reply With Quote
Old 11-18-2011, 11:54 PM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Same as in your other thread, this

Code:
self.sliderController = [[SliderController alloc] init];
is a leak. I strongly suggest you read Brian's guide to properties here: http://www.iphonedevsdk.com/forum/ip...roperties.html
baja_yu is offline   Reply With Quote
Old 11-19-2011, 01:26 AM   #3 (permalink)
Registered Member
 
SundialSoft's Avatar
 
Join Date: Oct 2010
Location: Scotland
Posts: 176
SundialSoft is on a distinguished road
Default

Quote:
Originally Posted by aceiswild View Post
Hey guys, i am getting a Potential Leak of an Object Allocated in the given code below. I am assuming i am not releasing something somewhere. There are no other leaks in my project besides this one. Do i need to declare something in my .M class?


AppDelegate .M:
Code:
 
#import "SliderPuzzleAppDelegate.h"
#import "SliderController.h"


@implementation SliderPuzzleDemoAppDelegate

@synthesize window;
@synthesize sliderController;
@synthesize vc;

- (void)applicationDidFinishLaunching:(UIApplication *)application {   

    self.sliderController = [[SliderController alloc] init];
    [window addSubview:sliderController.view];  <----- Potential Leak
    [window makeKeyAndVisible];

}

- (void)dealloc {
    [sliderController release];
    [window release];
    [super dealloc];

}


@end
Have you considered ARC. If it's not a huge project it will convert easily & then it's bye bye retain release blues for ever. My 2nd app was written much faster than the first due to ARC. Testing time goes down as well.
SundialSoft is offline   Reply With Quote
Old 11-19-2011, 08:16 AM   #4 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by SundialSoft View Post
Have you considered ARC. If it's not a huge project it will convert easily & then it's bye bye retain release blues for ever. My 2nd app was written much faster than the first due to ARC. Testing time goes down as well.
Except that even with ARC, you need to understand the rules of memory management. ARC means you have less places to screw up, but if you don't understand when to declare things as strong, and when to use weak, and when you need to nil out pointers, you will still have problems.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 11-19-2011, 08:59 AM   #5 (permalink)
Registered Member
 
ebender001's Avatar
 
Join Date: Mar 2010
Location: Missouri
Age: 57
Posts: 70
ebender001 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
Except that even with ARC, you need to understand the rules of memory management. ARC means you have less places to screw up, but if you don't understand when to declare things as strong, and when to use weak, and when you need to nil out pointers, you will still have problems.
I can't believe that all of the responders are such CONTROLLERS and won't let this guy SLIDE so that he can be RELEASED from his misery!

Ed
ebender001 is offline   Reply With Quote
Old 11-19-2011, 10:46 AM   #6 (permalink)
Registered Member
 
aceiswild's Avatar
 
Join Date: Oct 2011
Location: Canada
Posts: 62
aceiswild is on a distinguished road
Default

Quote:
Originally Posted by ebender001 View Post
I can't believe that all of the responders are such CONTROLLERS and won't let this guy SLIDE so that he can be RELEASED from his misery!

Ed
Haha I like that one. I actually can slide my pieces around. Rigt now I'm just doing some extreme cleaning of my code because I had a rough copy and good copy so I'm just fixing some things!

Steve
__________________
Don't be a quitter! Never give up and keep pushing to succeed at the things you love!
aceiswild is offline   Reply With Quote
Reply

Bookmarks

Tags
leak, potential leak of object

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 389
18 members and 371 guests
7twenty7, Alex-alex, Apptronics RBC, baja_yu, chiataytuday, dre, Duncan C, e2applets, ipodphone, jeroenkeij, leostc, matador1978, mbadegree, n00b, pbart, QuantumDoja, Retouchable, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:28 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0