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();