Library overview
Memory management
For optimal performance the library uses its own memory management system. It handles allocation requests and controls object lifetime.
The Context class is the core of the memory management system. All the library's memory allocation requests are routed to the current context.
Creating a context is as simple as declaring a Context object on the stack. This makes the newly created context the current context for the current thread and the previous active context (if any) is saved. After the object is destroyed (i.e. goes out of scope) the previous context becomes the current one once again.
Each thread has a separate context chain, context operations in one thread do not affect other threads.
Memory allocated within a context cannot be deallocated explicitly. It is freed when the context is destroyed.
All classes which are allocated by the context are derived from the BaseObject class. The context keeps track of objects derived from ManagedObject and calls their destructors when it is destroyed.
A context can also be allocated on the heap or as a global variable. The Context::MakeCurrent member function can be used to explicitly set any context as the current one.