PrimoBurner(tm) 3.6.1 for C++
Memory Management

Memory management is fundamental to using PrimoBurner effectively and efficiently. This topic is essential reading for all developers who use PrimoBurner. 

 

For managing memory PrimoBurner uses a reference-counting mechanism, and a policy of object ownership that is suggested by the names of classes and methods. 

 

Ownership Policy 

 

Applications using PrimoBurner constantly access and create and dispose of objects. In order to ensure that you do not leak memory, PrimoBurner defines rules for getting and creating objects. 

 

When trying to understand memory management in a PrimoBurner application, it is helpful to think not in terms of memory management per se, but instead in terms of object ownership. An object may have one or more owners; it records the number of owners it has using a reference count. If an object has no owners (if its reference count drops to zero), it is disposed of (freed). PrimoBurner defines the following rules for object ownership and disposal. 

 

  • If you obtain an object from a class that has a public Release method, you own the object and you must relinquish ownership when you have finished using it (using the Release method).
  • If the object you get is from class that does not have a public Release method, you do not own the object and you should not dispose it.
  • Classes that do not have a public Release method are called "reference types". The names of all reference types end with the "Ref" suffix.

 

 

Naming Conventions 

 

There are many ways in which you can get a reference to an object using PrimoBurner. In line with the PrimoBurner ownership policy, you need to know whether or not you own an object returned by a function so that you know what action to take with respect to memory management. PrimoBurner has established a naming convention for its classes and functions that allows you to determine whether or not you own an object returned by a function. In brief, if a function name does not end with "Ref", you own the object. If a function name ends with "Ref", you do not own the object.