简体   繁体   English

游戏退出后内存泄漏

[英]Memory leak after game is quit

i have a question about cocos2d-x memory leak in IOS.i just google this but not found a satisfied answer,so i hope i can get hep from here. 我在IOS.i中有一个关于cocos2d-x内存泄漏的问题,我只是用谷歌搜索但未找到满意的答案,所以我希望我能从这里得到帮助。 first,i am using the version 2.2.5,i know when we create a sprite via create(),its retainCount will be 1,if we added this sprite to a CCArray,its retainCount will be 2.if we want to delete it,just make sure its retainCount become 0,thus cocos2d-x engine will help us delete it from memory.my problem is in IOS,do we need to reclaim the memory manually when the game is quit or killed? 首先,我使用的是2.2.5版本,我知道当我们通过create()创建一个sprite时,如果将其添加到CCArray上,则其keepCount将为1,如果要删除它,则其keepCount将为2。 ,只需确保其keepCount变为0,那么cocos2d-x引擎将帮助我们将其从内存中删除。我的问题是在IOS中,我们是否需要在游戏退出或杀死时手动回收内存?

1.i do not see any callback function which is about game ends 1.i没有看到与游戏结束有关的任何回调函数

2.suppose there is a such callback function(called when application is end),do we need to manually reclaim memory in here?eg for my example,there is some global variables whose retainCount is 2,do we need to release it again in here? 2.假设有一个这样的回调函数(当应用程序结束时调用),我们是否需要在这里手动回收内存?例如,对于我的示例,有一些全局变量的retainCount为2,是否需要再次释放它?这里?

3.if we don't care the memory leaks when game ends,does it means it is possible lead to memory leak when game ends? 3.如果我们不关心游戏结束时的内存泄漏,是否意味着游戏结束时可能导致内存泄漏? any suggestion means a lot for me,thx! 任何建议对我来说都意义非凡!

The allocated memory is all within your process space so is all recovered when your process ends. 分配的内存全部在您的进程空间内,因此在进程结束时将全部恢复。 It is not possible leak memory when your app ends. 当您的应用结束时,不会出现泄漏内存。 You only need to worry about memory usage while your app is running. 您只需要担心应用程序运行时的内存使用情况。

See interesting article here 在这里看到有趣的文章

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

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