Singleton Destructors

后端 未结 12 1735
一整个雨季
一整个雨季 2021-01-31 03:55

Should Singleton objects that don\'t use instance/reference counters be considered memory leaks in C++?

Without a counter that calls for explicit deletion of the singlet

12条回答
  •  臣服心动
    2021-01-31 04:41

    Any heap memory allocated by your process and not freed (deleted) will be reclaimed by the OS. If you're using the most common implementation of the singleton, which uses static variables, this would be cleaned up upon your application's termination as well.

    *This does not mean that you should go around new-ing pointers and never cleaning them up though.

提交回复
热议问题