In game development, when is smart pointer used in engine development? Features of Modern game engine development:
- Large Scale
- Efficiency is the core competitiveness
- Multithreading and other features customized by hardware
When considering whether to use smart pointer, efficiency is inevitable.
The property of smart pointer is to manage yourself and destroy it if no one needs it.
In this case:
- When the resource owner is unknown, use smart pointer.
- When the resource owner is clear (that is, there is no need to manage itself), the owner is responsible for memory management.
- As a memory leak processing method, I personally do not like it very much. smart pointer is not the only processing method, and it is annoying to constantly increase, decrease, and decrease.
- It is not good either as a parameter or a return value. It is completely unnecessary. It should be done using the internal raw pointer, and then the smart pointer will be wrapped up when it comes to the home location.
- Multithreading security. At present, it seems that a better method is to set the thread to which it belongs during initialization, and then execute the assert of the thread in the runtime of a non-shipping version.