Created
February 27, 2012 06:51
-
-
Save patelrohan/1922022 to your computer and use it in GitHub Desktop.
Memory Leaks and Bad memory usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//===================== Memory Leak=========================== | |
NSString *str =[[NSString alloc]initwithFormate:@"Hello"]; | |
UILabel *lbl=[[UILabel alloc]init]; | |
lbl.text= str; | |
[str release]; | |
UILabel *lbl2=[[UILabel alloc]init]; | |
lbl2.text=str; // Gives memory leak as str is released | |
//=====================Bad memory usage=========================== | |
NSString *str =[[NSString alloc]initwithFormate:@"Hello"]; | |
UILabel *lbl; | |
lbl.text= str; | |
// bad memory usage as allocated string object is not released. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment