Menu

#129 Memory Leak in TOcRegistrar

unspecified
open
nobody
OCF (33)
1
2014-10-10
2011-01-28
No

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

Discussion

  • Sebastian Ledesma

    TUnknow::GetRefCount() it's not accesible from TOcRegistrar. We can delete it directly but first ensure that the object it's not shared.

     
  • Vidar Hasfjord

    Vidar Hasfjord - 2012-09-25
    • milestone: 6.30.10 --> 6.40
     
  • Vidar Hasfjord

    Vidar Hasfjord - 2014-04-26
    • Group: 6.40 --> unspecified
     

Log in to post a comment.