From 2bf19d10954a9fe89aaf7aaa099e02b2e3d6d7c1 Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 22 Jul 2024 23:58:06 +0200 Subject: [PATCH] Dispose of readers after load --- OSM_Regions/RegionLoader.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OSM_Regions/RegionLoader.cs b/OSM_Regions/RegionLoader.cs index 7266419..7d7abff 100644 --- a/OSM_Regions/RegionLoader.cs +++ b/OSM_Regions/RegionLoader.cs @@ -69,6 +69,8 @@ public class RegionLoader(float regionSize, string? importFolderPath = null, ILo } } } + nodesReader.Dispose(); + waysReader.Dispose(); return ret; } @@ -76,7 +78,7 @@ public class RegionLoader(float regionSize, string? importFolderPath = null, ILo public Graph.Graph? LoadRegionFromNodeId(ulong nodeId) { logger?.LogDebug($"Loading Region for Node {nodeId}"); - StreamReader nodesMapFileStream = new(Path.Join(ImportFolderPath, NodesMapRegionFileName), Encoding.ASCII); + using StreamReader nodesMapFileStream = new(Path.Join(ImportFolderPath, NodesMapRegionFileName), Encoding.ASCII); while (!nodesMapFileStream.EndOfStream) { string? line = nodesMapFileStream.ReadLine(); @@ -101,7 +103,7 @@ public class RegionLoader(float regionSize, string? importFolderPath = null, ILo public Graph.Graph?[] LoadRegionsFromWayId(ulong wayId) { logger?.LogDebug($"Loading Region for Way {wayId}"); - StreamReader waysMapFileStream = new(Path.Join(ImportFolderPath, WayMapRegionFileName), Encoding.ASCII); + using StreamReader waysMapFileStream = new(Path.Join(ImportFolderPath, WayMapRegionFileName), Encoding.ASCII); while (!waysMapFileStream.EndOfStream) { string? line = waysMapFileStream.ReadLine();