views:

63

answers:

1

I have checked using instruments and not found any memory leaks. when i check in device it shows memory leaks with responsible caller -[NSKeyedUnarchiver decodeObjectForKey:] and object is UIRoundedRectButton.

I still not using NSKeyedUnarchiver or any type of decoding. Is following code, is responsible for this memory leak ?

- (void)saveToFile:(NSString *)pinStr
{
 NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES); 
 NSString *documentsDirectoryPath = [paths objectAtIndex:0]; 
 NSString *path = [documentsDirectoryPath stringByAppendingPathComponent:@"smsbrain.plist"]; 

 NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
 [data setObject:@"User" forKey:@"username"];
 [data setObject:@"password" forKey:@"password"];
 [data setObject:pinStr forKey:@"pin"];
 [data writeToFile:path atomically:YES];
 [data release];
}

Or i have checked through internet & also some post on stackoverflow but not find any better solution.

I am not setting outlet to nil in viewdidunload & in dealloc methods. is it create any problem?

my application hides background when this leaks occur. and on console i get warning "Memory level is not normal (20 %)"

So, what to do for the problem of invisible of background of tableviewcontroller. it is working fine on simulater. but what is problem in device that it sometime hide background.

please help me...

+1  A: 

If you are not doing any NSCoding on yourself, the responsible caller is most likely a UIViewController that is decoding it's nib file. The memory warning you receive fits into this assumption.

When a memory warning is raised the standard implementation of UIViewController will release it's view, if is not visible (doesn't have a superview). As a result all subviews of that view will receive a release message and be dealloced, if no one retains them. But normally the viewController will at least retain some of it's view subviews trough it's IBOutlet properties. This is were viewDidUnload comes into play. It's called right after the view was unloaded (mostly due to a memory warning). This is the place were you really should release all retained subview of your view. That is every IBOutlet and erverything you created in viewDidLoad. There's really no need to hold them. They will all be recreated from the nib when needed.

In your dealloc method you have to release all retained properties and all retained ivars, that do not back a property. Please read the Memory Management Programming Guide

If this doesn't help. We would need your property declarations and the viewDidLoad, viewDidUnload, dealloc methods of the Controller in question.

tonklon
Hiren Gujarati
Hiren Gujarati