{"id":4043,"date":"2014-03-30T07:20:54","date_gmt":"2014-03-30T07:20:54","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/cocos2d-using-gobs-of-memory-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:20:54","modified_gmt":"2014-03-30T07:20:54","slug":"cocos2d-using-gobs-of-memory-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/cocos2d-using-gobs-of-memory-collection-of-common-programming-errors\/","title":{"rendered":"cocos2d using gobs of memory-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m having the absolute worst time with running out of memory in my game with cocos2d.<\/p>\n<p>I have 4 scenes. two vanish from memory when I switch scenes using<\/p>\n<pre><code>[[CCDirector sharedDirector]replaceScene:sceneWithTransition]\n<\/code><\/pre>\n<p>I&#8217;ve tried push\/pop and it makes the problem about 10x worse.<\/p>\n<p>2 of the scenes however are like a virus. The conditions under which I can remove them from memory do not exist. I am using the ARC alterations. I was hoping they would help, they did not.<\/p>\n<p>I&#8217;ve overridden the cleanup method to make sure I get rid of references to everything in the scenes. The first one is the game play scene, and I can imagine how it might be possible that I&#8217;ve missed something that is somehow holding on to the scene. However the other one is the settings scene. It has 5 parts. they all get tossed and yet the scene will not purge. before converting to ARC the app was unusable it crashed so often and when it wasn&#8217;t crashing it was running out of memory. After ARC it lasts about 4x longer than before but still runs out of memory regularly. Crashes however are almost non-existant.<\/p>\n<p>I suppose first off, what is the correct way to switch between scenes? Second, how does one remove something from memory when using arch because object = nil does nothing. All of my other programs using ARC run like dreams. None of them use the cocos2d engine. I&#8217;d not seen a memory error since the introduction of arc until I made the mistake of converting my quartz2d game in to cocos2d. The only reason I don&#8217;t o back to a platform that actually functions is that I really like the effects possible in cocos that I simply cannot make work in quartz.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m having the absolute worst time with running out of memory in my game with cocos2d. I have 4 scenes. two vanish from memory when I switch scenes using [[CCDirector sharedDirector]replaceScene:sceneWithTransition] I&#8217;ve tried push\/pop and it makes the problem about 10x worse. 2 of the scenes however are like a virus. The conditions under which [&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-4043","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4043","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=4043"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4043\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}