iphone - NSTimeInterval memory leak -
i have weird memory leak nstimeintervall , nsdate. here code:
nstimeinterval interval = 60*60*[[[config alloc] getcachelifetime] integervalue]; nsdate *maxcacheage = [[nsdate alloc] initwithtimeintervalsincenow:-interval]; if ([date compare:maxcacheage] == nsordereddescending) { return yes; } else { return no; } date nsdate object, should fine. instruments tells me "interval" leaks, yet not quite understand this, how can release non-object? function ends after code snippet posted here, understanding interval should automatically deallocated then.
thanks lot!
it telling leak happening on line.
the expression [[[config alloc] getcachelifetime] integervalue] problem.
first of all, care creating object (calling alloc) lose reference before calling release or autorelease, leaking.
also, ought call init method after allocating object. if config class doesn't special, nsobject's init method need called.
if replace line with
config *config = [[config alloc] init]; nstimeinterval interval = 60*60*[[config getcachelifetime] integervalue]; [config release]; that leak should plugged up.
you leaking maxcacheage object. inserting [maxcacheage autorelease]; before if statement should fix that.
Comments
Post a Comment