iphone - when I build and analyze, I got potential leak on at this point -
(bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { [self.window addsubview:rootcontroller.view]; [self.window makekeyandvisible]; [[controlfile alloc]scedule1]; return yes; }
i got potential leak of object allocated on [[controlfile alloc]scedule1] when build & analyze
[[controlfile alloc]scedule1];
this allocating instance of class controlfile
, calling scedule1
on allocated object. (note it's not yet initialized; should have initialized first calling init
). object (which allocated) never referenced again. thus, have leaked it.
you need this:
id controlfile = [[controlfile alloc] init]; [controlfile scedule1]; [controlfile release];
this assumes controlfile
class. if it's instance variable (as indicated lowercase text , lack of declaration in code), want this:
controlfile = [[whateverthedeclaredclassofcontrolfileis alloc] init]; [controlfile scedule1]; // in -dealloc method, call this: [controlfile release];
for every call alloc
, must call either release
or autorelease
when done object. not doing here, , have leaked object.
Comments
Post a Comment