A computer-assisted design program widely used to prepare drawings, plans, details, schematics, schedules, diagrams and other graphic illustrations. An example of SoftwareEvolution?, where each new version of the software improves the operation and usability to fit the users' needs. Produced by AutoDesk and is currently in its 16th or 17th generation.
Most recent versions of AutoCad are bundled with a VisualLispIde (VLIDE) and VisualBasicForApplications (VBAIDE).
An AutoCad AntiPattern:
This will act like a MemoryLeak: AutoCad will create the entities, but it will not remove them from memory. Instead, it will mark them for deletion. The entities will stay in memory until the drawing closes, or until AutoCad runs out of memory and fatal errors.
This is an AntiPattern because it crashes AutoCad, and causes the user to lose their work.
Indeed, AutoCad creates as many database objects as needed. When those objects are deleted from the database, they are simply marked as deleted; they are not explicitly deallocated from memory.
However, each business object in the system is managed with the aid of a TombStone called an ObjectId?. All references to business objects are held through their corresponding ObjectId?s. When a pointer to object is needed, the client must request the object to be opened.
AutoCad performs it own paging which is independent from the OS. The objects marked as deleted are the first to get paged to disk, leaving only their corresponding TombStones behind.
The TombStones also help AutoCad better manage transactions and serialization.
The problem with the first approach is that AutoCad assumes that every entity (except for SelectionSets) is a permanent business object. AutoCad assumes that any changes to the entity might need to be undone later. AutoCad does not understand that the deleted object was temporary, and that there is no need to retain it in memory.
A second approach, that is better in some situations:
A third approach, recommended by AutoDesk for temporary selection sets:
While it is a good idea to avoid the first approach, there are times when it is the most straightforward way to write an AutoCad macro. (For example, if a drawing needs to be compared to hundreds of images.)
One work-around is to have the macro pre-emptively close and re-open the drawing after every nth image, before AutoCad uses up too much (virtual) memory and crashes.
Crashes Not with skilled use
In over 10 years of using AutoCad to produce thousands of designs, I never had such problems. In that period of time, I cannot think of once where AutoCad crashed in the process of creating, copying, moving or updating an entity. Not saying it cannot happen, but the skilled use of the product will result in good designs with increasingly more complex and reusable entitites, designs, menus and drawing packages. -- DonaldNoyes