{"id":4049,"date":"2014-03-30T07:21:26","date_gmt":"2014-03-30T07:21:26","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/releasing-uiimage-after-use-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:21:26","modified_gmt":"2014-03-30T07:21:26","slug":"releasing-uiimage-after-use-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/releasing-uiimage-after-use-collection-of-common-programming-errors\/","title":{"rendered":"Releasing UIImage after use-Collection of common programming errors"},"content":{"rendered":"<p>I want to learn the right way to alloc an uiimage and release it for memory management. When i use the following code it crashes when deallocating, if i dont use [imager release];<\/p>\n<p>program doesnt crash but it shows a leak for imager. Any ideas for solution?<\/p>\n<pre><code>UIImage *imager = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:s@\"nameofimage\" ofType:@\"jpg\"]];\nUIImageView *imageView = [[UIImageView alloc] initWithImage:imager];\n\n[imageView release];\n\n[imager release];\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I want to learn the right way to alloc an uiimage and release it for memory management. When i use the following code it crashes when deallocating, if i dont use [imager release]; program doesnt crash but it shows a leak for imager. Any ideas for solution? UIImage *imager = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:s@&#8221;nameofimage&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4049","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4049"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4049\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}