From 0ec5989bd4e70b76d20c0932121344c57db3b027 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Mon, 8 Sep 2025 12:49:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8A=E6=94=BE=E7=A2=B0=E6=92=9E=E7=9A=84CO?= =?UTF-8?q?M=20API=E5=86=85=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Core/Collision/ClashDetectiveIntegration.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Core/Collision/ClashDetectiveIntegration.cs b/src/Core/Collision/ClashDetectiveIntegration.cs index b9061f7..a0a65a9 100644 --- a/src/Core/Collision/ClashDetectiveIntegration.cs +++ b/src/Core/Collision/ClashDetectiveIntegration.cs @@ -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;