释放碰撞的COM API内存

This commit is contained in:
tian 2025-09-08 12:49:29 +08:00
parent 235529315e
commit 0ec5989bd4

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.Clash;
@ -1737,10 +1738,21 @@ namespace NavisworksTransport
}
// 清理引用,防止内存泄漏
if (_clashElement != null)
{
try
{
Marshal.ReleaseComObject(_clashElement);
}
catch (Exception comEx)
{
LogManager.Warning($"释放Clash Element COM对象失败: {comEx.Message}");
}
}
_clashElement = null;
_dynamicClashTest = null;
_documentClash = null;
_state = null;
_state = null; // 不释放,这是全局单例
_isInitialized = false;