From ae7d6a307723d1d01a92da598b03a9275c62fb2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BChlegger?= Date: Mon, 12 Oct 2026 16:18:35 +0200 Subject: [PATCH] fix: Add method to clear the block cache (prevent OutOfMemory exception for huge projects) --- .../Projectfolders/Step7V5/BlocksOfflineFolder.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/LibNoDaveConnectionLibrary/DataTypes/Projectfolders/Step7V5/BlocksOfflineFolder.cs b/LibNoDaveConnectionLibrary/DataTypes/Projectfolders/Step7V5/BlocksOfflineFolder.cs index 32894b78..00a72b92 100644 --- a/LibNoDaveConnectionLibrary/DataTypes/Projectfolders/Step7V5/BlocksOfflineFolder.cs +++ b/LibNoDaveConnectionLibrary/DataTypes/Projectfolders/Step7V5/BlocksOfflineFolder.cs @@ -65,6 +65,19 @@ public List BlockInfos get { return readPlcBlocksList(); } } + /// + /// Drops the converted blocks cached on this folder's block infos, so they can be garbage collected. + /// Call this when converting many blocks one after another, otherwise every converted block stays in memory. + /// + public void ClearBlockCache() + { + if (_intBlockList == null) + return; + + foreach (var blkInfo in _intBlockList) + blkInfo._Block = null; + } + /// /// Read all blocks from the S7 Project and cache them into the 'tmpBlocks' field. ///