简体   繁体   English

Cocos-2d:ReplaceScene期间内存泄漏

[英]Cocos-2d : memory leak during ReplaceScene

I have two Levels level1.mm and level2.mm 我有两个级别:level1.mm和level2.mm

In Level1.mm i use button named "skip level" MenuItem to Replacescene to go to level2.mm ,But when that method gets called, my app crashes with exec bad access. 在Level1.mm中,我使用名为“ skip level” MenuItem的按钮来Replacescene转到level2.mm,但是当调用该方法时,我的应用程序崩溃,并执行错误。

But if i use PushScene its going to level2 scenes properly.But I know somewhere memory will be waste if i use pushscene. 但是如果我使用PushScene可以正确地进入level2场景。但是我知道如果我使用Pushscene会浪费内存。

What is the bestway to replace scene?should i call any dealloc before replacescene or it will be called automatically? 替换场景的最佳方法是什么?我应该在replacescene之前调用任何dealloc还是它将被自动调用?

note : Please Be gentle this is my first game in iphone :) :) 注意:请保持谦虚,这是我在iPhone上的第一个游戏:) :)

The fact that replaceScene crashes but pushScene does not tells me that the first scene has some kind of issue when it is being deallocated. replaceScene崩溃但pushScene崩溃的事实并没有告诉我,第一个场景在被释放时存在某种问题。 So your question isn't about how to replace scenes, but rather how to find and fix the bug that causes the crash. 因此,您的问题不是关于如何替换场景,而是关于如何查找和修复导致崩溃的错误。

Try this tutorial to learn more about debugging with Xcode. 尝试本教程以了解有关使用Xcode进行调试的更多信息。 And since you're new, you probably aren't using ARC yet . 而且由于您是新手,所以您可能还没有使用ARC Do that now because it'll help to avoid a ton of similar issues. 现在就这样做,因为这将有助于避免大量类似的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM