The constructor for TOcRegistrar creates a TOcClassMgr object, then adds a reference (to meet the COM specification).
The destructor of TOcRegistrar decreases the reference for the OcClassMgr object but don't delete it.
Proposed solution:
TOcRegistrar::~TOcRegistrar() {
...
if (OcClassMgr) {
OcClassMgr->Release();
if (!OcClassMgr->GetRefCount()) {
delete OcClassMgr;
}
...
}
It seems that the OcClassMgr it's not shared with any other object: there isn't any member function TOcRegistrar that returns the private OcClassMgr pointer
and the friend class TOcApp don't refers to it, so we can optimize and delete OcClassMgr directly.
Sebas
TUnknow::GetRefCount() it's not accesible from TOcRegistrar. We can delete it directly but first ensure that the object it's not shared.