C ++ Gotchas Chapter 6 Memory and Resource Management

zhaozj2021-02-08  323

Memory and Resource Management

6 memory and resource management

C provides great elasticity in memory management, but there is almost no C programmer fully transfers. C In this regard, via overloading, Name Hidding, Constructors and Destructors, Exceptions, Static Functions, and Virtual Functions, Operator functions and non-operator functions, together with extraordinary elasticity and customizable for memory management. Unfortunately - may inevitably - things become more complicated.

In this chapter, let's take a look at the various language features of C : how to use memory management; how to interact with each other in a surprising manner; how to reduce the interaction between it.

Memory is only one of the resources managed by the program, so we have to look at it, how to bind other resources to memory so that we can manage other resources using C memory management facilities.

6 memory and resource management

Gotcha # 60: Failure to Distinguish Scalar and Array AllocationGotcha clause 60: memory allocation fails to recognize a monomer to an array of memory allocation Gotcha # 61: Checking for Allocation FailureGotcha clause 61: Check allocation failure case Gotcha # 62: Replacing Global New and deleteGotcha clause 62: replace Global New and Global Delete Gotcha # 63: confusing Scope and Activation of Member new and deleteGotcha clause 63: survival and event space Member New and Member Delete the confusion Gotcha # 64: throwing String LiteralsGotcha clause 64: throw a String Literals Gotcha # 65: Improper exception MechanicsGotcha clause 65: not enough appropriate exception mechanism Gotcha # 66: abusing local AddressesGotcha clause 66: the abuse of local address space Gotcha # 67: Failure to Employ Resource Acquisition is InitializationGotcha clause 67: failed to uphold. " Resource Acquisition Is Initialization (Resource Getting Up to Initialization) "Gotcha # 68: Improper Use of Auto_PTRGOTCHA Terms 68: Improper Usage of Auto_PTR

转载请注明原文地址:https://www.9cbs.com/read-419.html

New Post(0)