is it okay to not use autorelease?


#1

I’m developing in cocos2d-x targeting iOS and am using the C11 dialect of C. Since I am already familiar with C++11 standard library smart pointers, std::unique_ptr and std::shared_ptr, I would like to use these smart pointers to manage memory in my application.

Will the cocos2d-x framework work correctly if I do not call pSomeCocos2dxObject~~>autorelease on my objects when I allocate them?
The standard cocos2d-x macro CREATE_FUNC helps declare a create member function that does two things:
Calls pSomeCocos2dxObject~~>init()
(2) Calls pSomeCocos2dxObject->autorelease()

So I understand I will need to do (1) myself. But if I don’t do (2) will that break things elsewhere in the framework?


#2

Yes, it will work properly. Some cocos2dx classes are designed to use autorelease pool and will use it but this won’t make a problem for you. You can also take a look at smart pointer class designed specially for use with cocos2d-x: https://github.com/ivzave/cocos2dx-ext