Dispose of readers after load

This commit is contained in:
glax 2024-07-22 23:58:06 +02:00
parent bea789f625
commit 2bf19d1095

View File

@ -69,6 +69,8 @@ public class RegionLoader(float regionSize, string? importFolderPath = null, ILo
} }
} }
} }
nodesReader.Dispose();
waysReader.Dispose();
return ret; return ret;
} }
@ -76,7 +78,7 @@ public class RegionLoader(float regionSize, string? importFolderPath = null, ILo
public Graph.Graph? LoadRegionFromNodeId(ulong nodeId) public Graph.Graph? LoadRegionFromNodeId(ulong nodeId)
{ {
logger?.LogDebug($"Loading Region for Node {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) while (!nodesMapFileStream.EndOfStream)
{ {
string? line = nodesMapFileStream.ReadLine(); string? line = nodesMapFileStream.ReadLine();
@ -101,7 +103,7 @@ public class RegionLoader(float regionSize, string? importFolderPath = null, ILo
public Graph.Graph?[] LoadRegionsFromWayId(ulong wayId) public Graph.Graph?[] LoadRegionsFromWayId(ulong wayId)
{ {
logger?.LogDebug($"Loading Region for Way {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) while (!waysMapFileStream.EndOfStream)
{ {
string? line = waysMapFileStream.ReadLine(); string? line = waysMapFileStream.ReadLine();