Описание тега object-lifetime

The object lifetime (or life cycle) of an object in object-oriented programming is the time between an object is created (also known as instantiation or construction) till the object is no longer used and then destructed or freed.

In typical case, the process is as follows:

  1. Memory allocation and binding: Calculate the size of the object (usually the alligned size of each member of the object), allocating memory space with the size of an object plus the growth later, if possible to know in advance and binding methods.
  2. Constructor call and execution: First the constructor of superclass(es) are called, then the constructor of the object.
  3. Object use.
  4. Destructor call and execution: First the destructor of the object are called, then the destructor(s) of the superclass(es).
  5. Memory deallocation and unbinding.