Home Page > KernelCAD Components > Memory Management
Memory management
Memory management
All objects, which expose interfaces, maintain internaly an integer value called reference count. Reference count is incremented when an interface has been queried from the object or another object inside the KernelCAD software obtained a reference to it. The reference count is decremented when an interface or reference is released. A reference-counted object is only deleted from memory during a release operation when the reference count has become zero
In most situation the reference counting is maintained internally by KernelCAD component and should not be modified. Sometimes, mosltly when normal flow of exection was interrupted by an exception, the reference count can become incorrect and the object can be over-released and prematurely deleted, which often causes an exception. On the other hand, reference count being incorrectly greater than the actual number of users, causes a memory leack. In either situations please report the problem to DInsight
In case you strongly suspect incorrect reference counting it can be investigated using IGlobalAPI_KC.GetRefernceCount() method. Quering an interface must increment the ref count. Releasing an interface (a variable which keeps the reference goes out of scope or has been set to null or nothing) must decrement it.
|