Object memory management
§
§Managed objects wrap an unmanaged C++ object!
§
§So we create them with New, Do they need to be disposed?
§No - garbage collection disposes the object when it wants to reclaim memory
§If the object is not in the database –– this deletes the underlying unmanaged object
§If the object is in the database – this Closes the underlying unmanaged object
§If opened in a transaction, disposing  or committing the transaction closes it automatically! – Clean memory management.
§
§
§
§
§
§
It is helpful to understand a few things about memory when we use the AutoCAD .NET API. The managed Objects in the .NET API are wrapped by unmanaged C++ objects. When we use the New keyword to create a new object you do not need to dispose of them because of the .NET garbage collection behaviour. If the object is disposed and it is not in the database the underlying unmanaged object is deleted. If the object is database resident the underlying unmanaged object is closed. If we use a transaction, which we will do most of the time, disposing or committing the transaction closes the unmanaged object. Now let’s put these ideas we covered in this presentation about the AutoCAD drawing database, ObjectId’s and transactions to work by going through lab three.