Smart pointer in gamedev

Source: Internet
Author: User
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.

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.