- UID
- 14
- 积分
- 8264
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-4
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Reclaiming memory of erased objects By Balaji Ramamoorthy
In AutoCAD, when an object is erased, it is marked as "erased" and the memory is not reclaimed until AutoCAD is closed. It is sometimes necessary to reclaim the memory of such erased objects without having to close AutoCAD, especially when large number of entities are being created and erased.
Please note that reclaiming the memory shoud not be used unless you absolutely need to. Also, please refer to the ObjectARX documentation regarding its usage.
Here is a sample to that uses the "Database.ReclaimMemoryFromErasedObjects" to reclaim the memory. As explained in the ObjectARX documentation, in some scenarios, AutoCAD may not be able to reclaim memory of erased objects. To check if the reclaim was successful, a simple test is to try and open the reclaimed object. If the object was actually reclaimed, AutoCAD throws a "Autodesk.AutoCAD.Runtime.Exception" with the ErrorStatus set to "ErrorStatus.PermanentlyErased".
Here is a sample code. To try this, first run the "SetupHeavyModel" command that creates about 5000 spheres at random locations. These spheres can be erased and the memory reclaimed using the "CleanDb" command. Just to ensure that this code does not stall your system, I suggest changing the number of entities to a smaller number (say 200) and then increase it if you do not see a visually detectable amount of memory getting allocated in the system resource monitor.
|
|