Because a lot of users have memory problem I've tried to seek why object are not deleted (some destructors were not called).
Normally when Smart pointer are smart enough to delete themselves.
When you put them in a map or a collection ref count is incremented. When Clear() method is called on these map or collection ref count is decremented etc...
But reality seems to show us lots of memory leaks. I've one suggestion for those who have memory leaks problems.
If you have lot of objects derived from Standard_Transient you can change Nullify() method and call this method at the end of your programm when you know you object are not used any more.
For Win32 :
In TKernel.dll project(FoundationClasses.dsw)
I've add commented lines to enforce deletion of object when calling .Nullify() method. Deletion is normally only obtained when reference count is equal to zero. So I decided Nullify() call would put definitively the reference counter to zero to delete the object.
It seems that in this case Nullify() can be called more than once.
// if (entity == UndefinedHandleAddress) return;
// entity->count = 1;
// endScope decrement entity->count and check if it's = 0 then delete()
entity = UndefinedHandleAddress ;